Link to other parts of my page in nav results in 404

I’m simply trying to link to another page on my site. I have a nav with a list of places on my site that I want to link to, but they all result in a 404 when clicked.

I want it to replace the current block of text when I click an option in the nav with whatever is similarly named in the content folder. So when I click “About” in my nav, I want it to display the text in the about.md file through the <main> in my baseof.html file.

Here’s my code: GitHub - Jaspev/first-hugo-site

How I understand my code working is that the first thing hugo loads is the baseof.html file located in layouts/_default, and that file is loaded on every single page.

In the baseof file, it is loading my nav as a partial. In my nav partial it is going through a range asking for every file in content that has the “type” variable = “nav” in it’s front matter, then lists everything it gets, and it sets every item’s href to {{ .RelPermalink }}. I’ve also tried “Permalink” instead of “RelPermalink” and it didn’t work.

In the baseof file it is also setting the main part of the page to simply be {{ .Content }}.

I’m not using any theme.

This is my hugo env:

hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended windows/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=gohugoio
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.21.5"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"

Thank you! :slight_smile:

The warning messages you see when you build your site are important.

WARN  found no layout file for "html" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

In your base template do this:

<main style="padding:20px; padding-right:0px;">
  {{ block "main" . }}{{ end }}
</main>

Then create layouts/_default/single.html

{{ define "main" }}
  {{ .Content }}
{{ end }}
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.