New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref/relref issue with duplicate base filenames #2507

kontsevoy opened this Issue Sep 28, 2016 · 3 comments


None yet
3 participants
Copy link

kontsevoy commented Sep 28, 2016

I have tried using relref to generate links to other parts of the site. In my case the generated links are broken, consider the following example:

~$: tree content/
├── teleport
│   ├──
│   ├──
│   ├──
│   ├──
│   └──

Inside of teleport/ I have a link declaration:

{{< relref "" >}}

And it generates /teleport/faq. I expect it to generate simply faq because the rendered page is already under /teleport. So the generated link is not relative at all, it's an absolute URL without a hostname.


This is a problem because such a page won't work if the generated HTML will be "mounted" into another subsection of a larger website, say /projects/teleport.

In fact, it doesn't even work in "pure Hugo" situations when you have two files in content/a/ and content/b/ - it will always produce to /a/faq for some reason


This comment has been minimized.

Copy link

bep commented Sep 29, 2016

This is as designed. If you want your site "mounted into" a larger website, you will have to use something other that relref, which, if the memory serves me correct, does produce links relative to the server root.

Understand that these links will be used not only from the page URL, but will also potentially be rendered on homepage, list pages etc., so a faq type relative URL wouldn't work.

If you want to address b/faq.mdyou should be able to:

{{< relref "b/" >}}

But looking at the code I see a bug where the order of the pages matters.

@bep bep changed the title relref always generates absolute URLs ref/relref issue with duplicate base filenames Sep 29, 2016

@bep bep added the Bug label Sep 29, 2016


This comment has been minimized.

Copy link

bep commented Sep 29, 2016

For the problem code line, see

It breaks out of the loop when match on base filename when it should have kept on looking for a more specific match if a "composite path" was provided as argument.

// cc @halostatue


This comment has been minimized.

Copy link

moorereason commented Dec 28, 2016

The line in question can be seen in commit a0167d8.

@bep bep added this to the v0.22 milestone May 25, 2017

@bep bep self-assigned this May 25, 2017

bep added a commit to bep/hugo that referenced this issue May 26, 2017

hugolib: Fix ref/relref issue with duplicate base filenames
This commit also makes that function 80x faster.

Fixes gohugoio#2507

@bep bep closed this in 612f6e3 May 26, 2017

@ghost ghost referenced this issue Jun 12, 2017


spf13/hugo v0.22 released #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment