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

Hello,

I am currently working on the following page: https://pauernet.gitlab.io/hugo-starter-2/

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 https://www.pauernet.de/, but now points to https://www.pauernet.de/hugo-starter-2.
For a subpage like Imprint, it points to https://www.pauernet.de/hugo-starter-2/en/imprint/.

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

The project is here: https://gitlab.com/pauernet/hugo-starter-2
In this file: https://gitlab.com/pauernet/hugo-starter-2/-/blob/master/layouts/partials/meta_schema.html (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 https://someurl.com/with/some/folders

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.

2 Likes

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