I know this is really simple and dumb but,
I have an index page at root/layouts/index.html
which is of course served when you go to the root url, but if I add a file root/layouts/blah.html
I can’t link to blah.html
within the index.html
with the usual
<a href="blah.html">blah blah</a>
how would I link to another .html file?
Files in ./layouts
are templates, so I’m not sure why you’re wanting to link to blah.html
.
Instead, you should have some markdown files which will use the template blah.html
to build static html pages.
If you want to have a regular HTML file, and not use any templating/layouts for it, it should be put in static/blah.html
.
If you want to link within layouts you can construct your URLs manually with the help of Hugo and methods like urlize
and path.Join
. This is particularly helpful for list pages. But if you just need to link to a page or other anchor such as a heading you’re probably looking for relref
.
This appears to be the answer I’m looking for, but I’m not sure what path to put in… I’ve always been a little confused about how hugo treats paths to directories.
I have my main index.html file in ./layouts/index.html
and I’m trying to link to another html file ./layouts.blah.html
. I’ve tried to link to it with
{{ ref "/layouts/blah.html" }}
{{ ref "/layouts/blah.html ." }}
{{ relref "/layouts/blah.html" }}
{{ relref "/layouts/blah.html" . }}
and other combinations of similar things, but I can’t quite figure out.