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

Closed
kontsevoy opened this Issue Sep 28, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@kontsevoy

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/
content/
├── teleport
│   ├── admin-guide.md
│   ├── architecture.md
│   ├── faq.md
│   ├── quickstart.md
│   └── user-manual.md
├── teleport.md

Inside of teleport/quickstart.md I have a link declaration:

{{< relref "faq.md" >}}

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.

Problem

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 faq.md files in content/a/faq.md and content/b/faq.md - it will always produce to /a/faq for some reason

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Sep 29, 2016

Member

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/faq.md" >}}

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

Member

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/faq.md" >}}

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

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

@bep bep added the Bug label Sep 29, 2016

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Sep 29, 2016

Member

For the problem code line, see https://github.com/spf13/hugo/blob/master/hugolib/site.go#L271

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

Member

bep commented Sep 29, 2016

For the problem code line, see https://github.com/spf13/hugo/blob/master/hugolib/site.go#L271

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

@moorereason

This comment has been minimized.

Show comment
Hide comment
@moorereason

moorereason Dec 28, 2016

Contributor

The line in question can be seen in commit a0167d8.

Contributor

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

Open

spf13/hugo v0.22 released #11

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