Issue with site navigation during deployment

Hi - Hugo newbie here. I’m having issues while deploying the site using Netlify. The navigation links(including the homepage link on the top left) are broken: clicking on ‘tags’ after ‘about’ renders the URL as
https://tender-wiles-5d6778.netlify.app/about/tags
instead of
https://tender-wiles-5d6778.netlify.app/tags

I understand there might be an issue with the baseURL config in my config.toml

I’ve tried setting the baseURL= "\"

I’ve also tried changing the menu URLs like this:
url = "\about"
which seems to fix the menu item but not the homepage link on the left.

Could someone please help? What am I missing here? Thanks in advance!

Info and Links

  1. GitHub repo: GitHub - schauhan/miniature-memory: Portfolio blog created in Hugo
  2. Hosted URL: https://tender-wiles-5d6778.netlify.app/
  3. Theme: PaperMod
  4. Deploying on Netlify
  5. I’ve added the theme as a submodule. Not sure if that makes a difference.

The URLs in your menu have no leading slashes on the URL so links resolve relative to the current page instead of the root.

1 Like

Thank you!

I added leading slashes to the menu items which now resolve correctly. However, my link to the homepage(the one with my name, on the top left) is still not resolving to root. Any advice on how can I fix this? (I tried checking the documentation for handling URLs but couldn’t find relevant info.)

In config.toml you must define a baseURL:

baseURL = "https://tender-wiles-5d6778.netlify.app/"

Thank you, @andreseduardop and @fgandiya. I added the netlify generated URL to the baseURL, and added leading slashes to the menu items. The navigation works correctly now.

Here’s my general question about Hugo: since netlify generates URLs dynamically I don’t have a way to know what link we’ll use before I actually deploy the app. Does that mean that I’ll have to change the base URL ever time the netlify URL changes, or is there a way to dynamically accept a generated url at deploy time? (Not a big issue, just asking for my understanding of best practices.)

Once Netlify generates the address it will not change.

Tip
You can change a site’s default Netlify subdomain by selecting the Options button next to the subdomain in the Custom domains panel, then selecting Edit site name in the dropdown.

1 Like

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