Links don't work = localhost: Page Not Found & site: 403 Forbidden

Need advice on where to look for possible cause.

Everything builds fine without errors:

~/Blog/blog-data master ❯ hugo server                                                                         15:47:21
Watching for changes in /Users/Den/Blog/blog-data/{archetypes,assets,content,data,static,themes}
Watching for config changes in /Users/Den/Blog/blog-data/config.toml, /Users/Den/Blog/blog-data/go.mod
Start building sites …
hugo v0.118.2-da7983ac4b94d97d776d7c2405040de97e95c03d+extended darwin/arm64 BuildDate=2023-08-31T11:23:51Z VendorInfo=brew

WARN  Current environment is "development". The "comment system", "CDN" and "fingerprint" will be disabled.

                   | EN  | ES  | DE  | RU  | SK
  Pages            | 133 | 136 | 135 | 138 | 133
  Paginator pages  |   3 |   3 |   3 |   3 |   3
  Non-page files   |   0 |   0 |   0 |   0 |   0
  Static files     | 218 | 218 | 218 | 218 | 218
  Processed images |   0 |   0 |   0 |   0 |   0
  Aliases          |  52 |  53 |  53 |  54 |  52
  Sitemaps         |   2 |   1 |   1 |   1 |   1
  Cleaned          |   0 |   0 |   0 |   0 |   0

Built in 793 ms
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address
Press Ctrl+C to stop

When I go to localhost then summary page shows correctly and displays all posts. All links look correctly. But clicking on any link, i.e. to open any post, gives ‘Page Not Found’.

On real site ( click on any link gives ‘403 Forbidden’.

Where would you start looking to find a possible cause?

PS. I didn’t change anything in the config. Updated the post today and wanted to see how it looks like on the localhost, but got this error ‘Page Not Found’. Didn’t pay much attention, thought it might be related to me working under VPN are alike. Then uploaded updated site and this was my mistake. Now site doesn’t work too. Will appreciate any ideas where to look for possible cause. Thanks.

Post a link to your code repo for the site and I’m sure we can help you find the issue.

Thank you for your prompt reply. I know about this requirement and want to avoid it. That’s why I am not asking to find potential bug for me, but share the ideas on where to look for it… If that is not possible, well, I’ll continue with google-fu…

The links may look correctly, but obviously they arent working. So it’s some faulty condition in the way those links are generated. You have to dig into your templates to find that location.

Most often handling of languages (if it is a multi lang setup) and/or handling/configuration of the BaseURL are the culprit.

If you are using a theme, you could reach out to the theme maintainer to get help.

Confirm if you have a single.html file in your templates and if your permalinks are configured correctly.

Thank you for your kind attention! I do have this file single.html in the _default folder. Currently looking at it too…

Thank you, @McShelby for your kind help! I think BaseURL is ok, it looks like this in config.toml:

# hostname and path to the root
baseURL = ""

So I am looking at link generation part now… Thanks for the suggestion!

Ok, I’ve sorta fixed the error and blog works again.

@Arif, you were correct - the bug was in this file. I’ve replaced it with an old copy from backup and everything works now. Will look for specific line with the bug.

Thanks everyone for the help!!

Should be baseURL = ""

1 Like

Off topic, but related to your site ( ), you have a weird glitch that causes every page to blink to light background before it goes back to the dark one. It is happening on macOS Safari, with dark mode enabled.

1 Like

@Fastidious, thanks for letting me know! It’s because I had to use old template from backup to restore blog at least temporarily… Now, when I found the bug, everything will be back to normal. Once again, your attention and desire to help is much appreciated! :handshake:

All right… I found the bug :face_with_peeking_eye: It’s a shame (to me), but the whole problem was in the following. I have put some stupid comment into single.html file right in the beginning, like so:

<!-- Here is some stupid comment in this format -->

{{- define "title" -}}
    {{ .Title }} - Den's Hub
{{- end -}}

And because of this comment not in {{- /* this format */ -}}, all links didn’t work.

Anyway, I learned something new today, and will adjust my workflow to test more thoroughly before deploying to the server.

Thanks again to everyone who helped and supported me here - very much appreciated! :heart:

1 Like