Linking to other pages from layouts/partials

Hi,

I have a partial containing header navigation links like:

<a class="nav-link" href="/persons">Persons</a>

and also from layout I’m linking to specific content pages with the same code.

This works in local development mode as it just goes to /persons in the root of the server.

Now for a preview environment I have set the baseURL with a deeper path like:
www.myserver.com/some-path/
and then the link is going to /persons instead of /some-path/persons.

I read about the rel and relref shortcodes but I cannot use these in layouts and partials.
What is the best way to link to other pages in layout/partials taking the baseURL (or at least the base path behind the host) into consideration?

This is the error I get when using ref btw:
In partial: {{< ref "/persons" >}}
Error: parse failed: template: partials/header.html:20: unexpected "<" in command

For your particular example you could do

href = ‘{{ “persons” | relURL }}’

Or something …

1 Like

ref needs a path to a markdown file …

Persons could do the trick

Thanks Bep,I was looking the wrong direction with the ref short code.