Links between pages in quarto website with qmd files in different subfolders
Asked Answered
G

1

5

I am creating a website with quarto (using RStudio). I want to have links between pages on my site, which usually works as described here in the quarto documentation. However, I have saved the .qmd files for my pages within separate subfolders within the project directory as shown in this example _quarto.yml:

website:
  title: "Main Title"
  navbar:
    title: "Navbar Title"
    left:
      - text: Pages
        menu:
          - text: Page A
            href: folderA/pageA.qmd
          - text: Page B
            href: folderB/pageB.qmd

When trying to add [link](folderB/pageB.qmd) anywhere within the pageA.qmd document, it incorrectly creates the link as folderA/folderB/pageB.qmd which obviously does not work.

How do I correctly assign links between pages in this setting?

Grewitz answered 31/10, 2022 at 11:1 Comment(1)
Check out the the R package here, which you can use to create paths relative to project root directory.Gauthier
G
6

It's a bit tedious but you should be able to use relative paths, i.e. .. to move to previous directory.

So in your case that would be [Link](../folderB/pageB.qmd). Not a great solution but as long as your directory structure stays the same, it should work.

If you later on find yourself changing the structure you can use aliases to keep the old links alive.

Germiston answered 11/11, 2022 at 17:53 Comment(1)
Thanks! Seems so obvious now. (┛ಠ_ಠ)┛彡┻━┻Grewitz

© 2022 - 2024 — McMap. All rights reserved.