How to set a canonical url with correct folder structure when hosted on gitlab pages


I am currently working on the following page:

if the page is built on GitLab pages, then the directory is the same as the project name: hugo-starter-2. The caonical URL should point to, but now points to
For a subpage like Imprint, it points to

How do I get the subdirectories out of my canonical URL?

The project is here:
In this file: (line 61) is my code.

I hope you can help me.

Thank you very much.

ps: The same happens when I build the page like this: hugo --minify --baseURL

I think the quickest solution could be to set canonifyUrls to true here:

If that does not do the trick, what your problem is, that you probably point to “imprint/” instead of “/imprint/” in those links that you want to point to the domain root. “/” at the beginning starts always at domain root.


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