I’m having trouble getting links between files working (feeling very stupid today!)
For example:
content
blog
post-1.md
post-2.md
In post-2.md I want to put a link to post-1.
e.g.
For more information, check out [post 1](post-1)
The problem I’m having is I can’t seem to get that to work in a nice way without it 404ing.
I have tried:
/post-1
/post-1.md
/post-1/
./post-1
etc.
In my config.yaml I had:
baseURL: /
relativeURLs: true
canonifyURLs: true
The baseURL needs to be / to play nice, as the built site gets pulled in to another site.
I have tried changing relativeURLs and canonifyURLs to false.
The only way I avoid 404s is to anticipate the output and have the following:
For more information, check out [post 1](../post-1)
This takes into account the fact that when built, everything ends up as an index.html in its own folder. But this is really nasty - I can probably remember and make sure to anticipate the build, but it’s likely to trip up other contributors to the project. There must be a more elegant way? It’s also tripping me up with adding images.
Edit to add: based off the docs here (https://gohugo.io/content-management/urls/#relative-urls) I would expect that with relativeURLs: true, putting /post-1/ would result in the the correct link. But instead I get a 404 to /blog/post-2/post-1
(am on 0.54.0)
Edit to add again: so I tried using the short code {{< ref “post-1” >}} and that worked. Are shortcodes the only way to do this? We’re losing the nice clean markdown (and low barrier to contribution) if writing with Hugo requires knowledge of Hugo-specific stuff.