简体   繁体   English

将 Bookdown 构建为 HTML 会丢失样式格式

[英]Building Bookdown to HTML loses styled formatting

I have a large Bookdown document that I want to host on a website as an HTML file.我有一个很大的 Bookdown 文档,我想将它作为 HTML 文件托管在网站上。 I use bookdown::gitbook to build into a website and the local preview looks fine.我使用bookdown::gitbook构建到一个网站,本地预览看起来不错。 However, when I host the html files in the website, they seem to lose the HTML styling and look pretty bad.但是,当我在网站中托管 html 文件时,它们似乎丢失了 HTML 样式并且看起来很糟糕。 Any workaround to this?有什么解决方法吗?

当我使用 Gitbook 构建 Bookdown 站点托管 HTML 时,漂亮的 Bookdown 样式似乎消失了

EDITED: Adding the yaml at the beginning of my Index.Rmd file:编辑:在我的 Index.Rmd 文件的开头添加 yaml:

   --- 
    title: "Team Documentation"
    author: "Maxx"
    date: "Updated on `r Sys.Date()`"
    knit: "bookdown::render_book"
    site: bookdown::bookdown_site
    bibliography: [book.bib]
    biblio-style: apalike
    link-citations: yes
    colorlinks: yes
    lot: yes
    lof: yes
    fontsize: 13pt
    monofontoptions: "Scale=0.7"
    description: "This is a collection of commonly used information and how-to documents"
    output:
      bookdown::gitbook:
        self_contained: true
        css: css/style.css
        split_by: section+number
        config:
          toc:
            collapse: section
            before: |
              <li><a href="./index.html">Documentation</a></li>
            after: null
          toolbar:
            position: fixed
          edit: null
          download: null
          search: yes
          sharing: false
          info: yes
      bookdown::html_book:
        css: css/toc.css
    ---

Arrived at a solution: Smashing the Bookdown Gitbook into a single self-contained html file to host on a static site was causing badness + extra maintenance steps, so I ended up ditching the static site and hosting as an Azure app service site instead.找到了一个解决方案:将 Bookdown Gitbook 粉碎成一个独立的 html 文件以托管在静态站点上会导致糟糕的情况 + 额外的维护步骤,所以我最终放弃了静态站点,转而托管为 Azure 应用程序服务站点。 My steps:我的步骤:

  1. Set up an Azure app service site设置 Azure 应用服务站点
  2. Create a Bitbucket repo创建一个 Bitbucket 存储库
  3. Build Bookdown Gitbook from R as normal (that is, as separate html pages as per intended use, not self-contained)像往常一样从 R 构建 Bookdown Gitbook(即根据预期用途作为单独的 html 页面,而不是独立的)
  4. Push Bookdown html files + css file to Bitbucket repo将 Bookdown html 文件 + css 文件推送到 Bitbucket 仓库
  5. Connect Bitbucket repo to Azure app service & deploy将 Bitbucket 存储库连接到 Azure 应用服务并进行部署
  6. There was one issue with the deployment, which the commands from this question helped resolve: https://stackoverflow.com/a/62016237/314763部署存在一个问题,该问题中的命令帮助解决了该问题: https : //stackoverflow.com/a/62016237/314763

This solution offers these advantages:该解决方案具有以下优势:

  • Pushing the Bookdown files to Bitbucket is simple in that it can be automated with Git将 Bookdown 文件推送到 Bitbucket 很简单,因为它可以使用 Git 自动化
  • Azure app service can have authentication added to it, which is a perk for my team Azure 应用服务可以添加身份验证,这对我的团队来说是一种福利

I hope this is helpful to others as well.我希望这对其他人也有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM