Search code examples
rrstudiobookdownquarto

How to embed a bookdown gitbook in a quarto website (as a navbar item)?


I have a quarto website and a .html file of a gitbook made with bookdown (located in a subfolder called _notes of the quarto website). How can I embed this gitbook within the quarto website?

The source code of the quarto website is available at: https://github.com/lnalborczyk/IMSB2022 The rendered version of the website (rendered via Github pages) is available at: https://www.barelysignificant.com/IMSB2022/

Now, I would like to redirect to the bookdown gitbook (i.e., the index.html file located in _notes/docs/) when I click on "Notes" in the navbar. Therefore, I have added the following command in my navbar options in _quarto.yml:

  navbar:
    pinned: true
    search: true
    background: "#1c5253"
    right:
      - syllabus.qmd
      - planning.qmd
      - content/index.qmd
      - resources.qmd
      - install.qmd
      - text: "Notes"
        href: "_notes/docs/index.html"

And also added the bookdown folder as a resource using:

  resources:
    - "files/"
    - "_notes/docs/"

This works locally (i.e., via "preview website"), but fails when rendering via Github pages (i.e., it gives a 404 error message).

Any idea on how to make it work online?

Thank you for your help!

Ladislas


Solution

  • OK, just found a solution. The problem came from the "_" prefix in my "_notes/docs", which seems to be interpreted by Github Pages / Jekyll as "do not build this file" (e.g., https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/about-github-pages-and-jekyll).

    Two solutions: either remove the "_" prefix in "docs/notes" (after rendering the website with Quarto) or (the solution I went for) output the bookdown gitbook directly in a folder at the root of the Quarto website in a folder that does not contain a "" prefix, such as "notes", then adding this folder to the resources in _quarto.yml (as I have done here: https://github.com/lnalborczyk/IMSB2022).

    Just sharing this in case it can help others!