简体   繁体   中英

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. I use bookdown::gitbook to build into a website and the local preview looks fine. However, when I host the html files in the website, they seem to lose the HTML styling and look pretty bad. Any workaround to this?

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

EDITED: Adding the yaml at the beginning of my Index.Rmd file:

   --- 
    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. My steps:

  1. Set up an Azure app service site
  2. Create a Bitbucket repo
  3. Build Bookdown Gitbook from R as normal (that is, as separate html pages as per intended use, not self-contained)
  4. Push Bookdown html files + css file to Bitbucket repo
  5. Connect Bitbucket repo to Azure app service & deploy
  6. There was one issue with the deployment, which the commands from this question helped resolve: 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
  • Azure app service can have authentication added to it, which is a perk for my team

I hope this is helpful to others as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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