Question for setting up Menu

So I went through the docs and copied down some of the menu settings, which mostly works with showing menu entries, and linking to external ones but I can’t seem to link to content I’ve created. So I generated a page titled about.md and put an entry for it in the config.toml but when the entry is clicked on in hugo server I get a blank page. Can someone let me know what piece I’m missing?

Config.toml

[menu]

[[menu.main]]
    name    = "About"
    identifier = "menu.about"
    url = "about/"

[[menu.main]]
    name    = "Merch"
    identifier = "menu.merch"
    url = "https://www.redbubble.com/"

Header:

<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">   
  <div class="container-fluid">
      <a class="navbar-brand" href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
      <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse"
          aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
      </button>
      <!-- Nav bar headers -->
      <div class="collapse navbar-collapse" id="navbarCollapse">          
          <ul class="navbar-nav me-auto mb-2 mb-md-0">                 
          {{ $currentPage := . }}
          {{ range .Site.Menus.main }}
             
            <li class="nav-item">
              <a class="nav-link {{ if $currentPage.HasMenuCurrent "main" . }}active" aria-current="page {{ end }}" href="{{ .URL }}">{{ .Name}}</a>
            </li>                         
             {{ end }}            
          </ul>
      </div>
  </div>  
</nav>

Page front matter

+++
title = "About"
date = 2022-08-25T15:14:52-04:00
draft = false
+++

You should not be seeing a 404 given the setup you describe above, so it would be helpful if you were to share a link to the public repository for your project.

Additional notes about menu entries in your site configuration:

  1. It is not necessary to define identifier unless two or more entries share the same name.
  2. Use pageRef instead of url for internal pages.

In your template you probably want to use .IsMenuCurrent instead of .HasMenuCurrent.

I managed to get it to stop showing a 404 but its still not showing any content. Also a weird issue pops up if I click the about link twice I get /about/about in the address bar is there a way to fix that?

Your site config

baseURL = ''         # Set this to something like https://example.org/
relativeURLS = true  # Why? Delete this line.

[[menu.main]]
name    = "About"
identifier = "menu.about"  # See my previous comment. 
url = "about/"             # Change this to pageRef = "/about.md"

Your templates are a bit of a mess. Read about base/blocks, or see this detailed example.

Thanks, and especially thanks for those links I got it sorted now!

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