Absolute URL with same domains as baseUrl

I got the following problem:
We are building links like that:

Nice text [`filename`](

Locally everything is fine and the link https://gitlab.domain.com/root/path/-/tree/development/path/to/filename is being rendered.

On the system, where we host the hugo site the link gets changed to:


We suspect that it might have anything to do with the basepath specified in the hugo.toml:

baseURL = 'https://gitlab.domain.com/root/path/'

Other absolute link (to external sites) are working fine.

Are you simply commenting on the the difference, or is something broken?

Is this a multilingual site?

Are you using a custom link render hook?

Where does “filename” reside in relation to the root of your project directory?

Which Hugo version?

Thank you @jmooring for the fast response!

My problem is, that the url gets rewritten with the current path of the document and breaks.

We are only using one language, and we don’t use custom link render hooks.
If that matters, we are using the books template:

So here is the correct example:

Should be:

Is (pay attention to the currentPath element):

And we are currently on page (if that makes any difference):

We are currently using hugo v0.126.1 as we are using registry.gitlab.com/pages/hugo/hugo_extended:latest to build the Hugo site.

The theme uses a link render hook:

And the answer to this question is…

While our baseURL is:

The target URL is

So toplevel domain is the same, but we got different subdomains. The target file is not even part of the Hugo site.

Thanks for pointing that out, I did not check that. But for me it seems fine, as this is mainly doing stuff with URL that are not “remote” URL (beginning with //or having a : in it)

OK, I’ve read through this thread several times and am still confused.

Can you share your project, specifically the entire config? And when you build your site, are you passing any command line flags?

I’m very sorry, for wasting everyones time here.
After further thorough investigation I found a small little sed line, that changes those links… :face_with_peeking_eye:

The fact that you were doing some pre/post processing outside of Hugo is a pretty important detail.

I’m glad you were able to figure it out.

If only I had known :wink:

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