Links from root break if deployed on a subdictory in ghpages (solved)

I have been using zola and for th most part it works fine, but while linking to different pages it breaks.

I have set the base url as:

# The URL the site will be built for
base_url = ""

And it gets deployed to githhub pages.

The problem arises when I link from a post say at /posts/migrating-to-zola/ to /about/ page. When I use [About](/about) this works fine in local server but breaks on deployment and if I use [About](/blag/about) this breaks in local server but works fine when deployed.

Is there a way to link these properly that the links work in both local server and when deployed?

I have tried [About](../../about) but it looks ugly and isn’t as clear, it requires knowing the current path and can’t be reused in different level directories.

The line with the concerning code is at migrating-to-zola/

You could use this shortcode:

As you suggested, the shortcode will solve my problem but it is one more complication and I wonder if there could be a better way to achieve this. For example if there was a setting in zola that inserted the base URL at the end of each link that began with a root / this problem wouldn’t occur and simple /about would work in both local server and when deployed.


isn’t this problem solved by using Zola internal links?

If you have base_url configured in config.toml to include the subdirectory in which your site is deployed then all internal links are created relative to that.

if you have:

base_url = ""

and use the following link in markdown:

test a link [link](@/

The following will be created:

<p>test a link <a href="">link</a></p>

it does always include the full URL including the domain, which is not necessary but it works.

Hope this helps


Thanks @Marco,
I didn’t realize that the .md extension was necessary for the deep linking to work, I thought it would work without it.
I tried the Internal link and it works like a charm! Thanks!