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

Builtin pagination template doesn´t work with sub root in BaseURL and CanonifyUrls = "false" #1252

Closed
donlzx opened this Issue Jul 7, 2015 · 11 comments

Comments

Projects
None yet
4 participants
@donlzx

donlzx commented Jul 7, 2015

If .Site.BaseURL contain paths (e.g., example.com/en/), pagination doesn't work correctly. The variables URL, Next.URL, Prev.URL, etc. return incorrect values in the pagination templates, resulting in the following behavior:

http://example.com/en/products/page/2/ (correct link) => http://example.com/products/page/2/ (links in generated pages)

I make it working by hacking the source code (hugolib/pagination.go) around line 276:

urlFactory := newPaginationURLFactory(section)

modified as:

urlFactory := newPaginationURLFactory(helpers.RelURL(section))

Since I am new to Hugo and haven't looked at the source codes before, can someone check this issue and fix it in a correct way?

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jul 7, 2015

Member

I'm pretty sure the Next.URL etc. are relative to context root, so the examples you give cannot be the string value returned. Can you check?

Member

bep commented Jul 7, 2015

I'm pretty sure the Next.URL etc. are relative to context root, so the examples you give cannot be the string value returned. Can you check?

@donlzx

This comment has been minimized.

Show comment
Hide comment
@donlzx

donlzx Jul 7, 2015

@bep Actually, I mean the final URL in the generated pages. Fixed my description.

donlzx commented Jul 7, 2015

@bep Actually, I mean the final URL in the generated pages. Fixed my description.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jul 7, 2015

Member

And how do you construct the "full URL"?

Member

bep commented Jul 7, 2015

And how do you construct the "full URL"?

@donlzx

This comment has been minimized.

Show comment
Hide comment
@donlzx

donlzx Jul 7, 2015

For testing, I'm just using the default internal template and nothing special:

  {{ range (.Paginator 20).Pages }}
       ....
  {{ end }}
  {{ template "_internal/pagination.html" . }}

The full URLs are constructed by the browser. To be exact, the links to the pages in generated HTML looks like:

 <a href="/products/page/2/">2</a>

It should be:

<a href="/en/products/page/2/">2</a>

donlzx commented Jul 7, 2015

For testing, I'm just using the default internal template and nothing special:

  {{ range (.Paginator 20).Pages }}
       ....
  {{ end }}
  {{ template "_internal/pagination.html" . }}

The full URLs are constructed by the browser. To be exact, the links to the pages in generated HTML looks like:

 <a href="/products/page/2/">2</a>

It should be:

<a href="/en/products/page/2/">2</a>
@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jul 7, 2015

Member

OK, now I understand it.

The current workaround is to either set CanonifyUrls = "true" or use a custom paginator template.

helpers.RelURL would be the right medicine, but I would do it with the rel variable here:

https://github.com/spf13/hugo/blob/master/hugolib/pagination.go#L367

Member

bep commented Jul 7, 2015

OK, now I understand it.

The current workaround is to either set CanonifyUrls = "true" or use a custom paginator template.

helpers.RelURL would be the right medicine, but I would do it with the rel variable here:

https://github.com/spf13/hugo/blob/master/hugolib/pagination.go#L367

@bep bep added the Bug label Jul 7, 2015

@bep bep changed the title from Pagination ignore baseURL setting to Builtin pagination template doesn´t work with sub root in BaseURL and CanonifyUrls = "false" Jul 7, 2015

@donlzx

This comment has been minimized.

Show comment
Hide comment
@donlzx

donlzx Jul 7, 2015

@bep Using helpers.RelURL() with rel variable doesn't work for me, because rel variable is already of the form /section/page/... and helper.RelURL() doesn't change it.

donlzx commented Jul 7, 2015

@bep Using helpers.RelURL() with rel variable doesn't work for me, because rel variable is already of the form /section/page/... and helper.RelURL() doesn't change it.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jul 7, 2015

Member

Hmm, that sound a little bit strange. I guess this should be a safe bet, too:

https://github.com/spf13/hugo/blob/master/hugolib/pagination.go#L273

Member

bep commented Jul 7, 2015

Hmm, that sound a little bit strange. I guess this should be a safe bet, too:

https://github.com/spf13/hugo/blob/master/hugolib/pagination.go#L273

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Mar 1, 2017

Member

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

Member

bep commented Mar 1, 2017

Note/Update: This issue is marked as stale, and I may have said something earlier about "opening a thread on the discussion forum". Please don't.

If this is a bug and you can still reproduce this error on the latest release or the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.

@bep bep referenced this issue Mar 13, 2017

Closed

Add custom output formats #2828

26 of 26 tasks complete

@bep bep self-assigned this Mar 14, 2017

@bep bep added this to the v0.20 milestone Mar 14, 2017

@bep bep removed the Stale label Mar 14, 2017

bep added a commit to bep/hugo that referenced this issue Mar 27, 2017

hugolib: Refactor/-work the permalink/target path logic
This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done.

This commit's goal is to say:

* Every file target path is created by `createTargetPath`, i.e. one function for all.
* That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on.
* The path creation logic has full test coverage.
* All permalinks, paginator URLs etc. are then built on top of that same logic.

Fixes #1252
Fixes #2110
Closes #2374
Fixes #1885
Fixes #3102
Fixes #3179
Fixes #1641
Fixes #1989

@bep bep closed this in 6bf010f Mar 27, 2017

@aureooms

This comment has been minimized.

Show comment
Hide comment
@aureooms

aureooms Jul 26, 2017

I still have the same issue in 0.20-DEV with the default paginator. baseurl is https://example.com/bla/ but the paginator generate /page/x urls. Is it supposed to have been fixed?

aureooms commented Jul 26, 2017

I still have the same issue in 0.20-DEV with the default paginator. baseurl is https://example.com/bla/ but the paginator generate /page/x urls. Is it supposed to have been fixed?

@moorereason

This comment has been minimized.

Show comment
Hide comment
@moorereason

moorereason Jul 27, 2017

Contributor

Yes, it's fixed been since the 0.20 release. Update your Hugo version. The latest is 0.25.1.

Contributor

moorereason commented Jul 27, 2017

Yes, it's fixed been since the 0.20 release. Update your Hugo version. The latest is 0.25.1.

@aureooms

This comment has been minimized.

Show comment
Hide comment
@aureooms

aureooms Jul 27, 2017

Sorry! I thought I had the latest version...

aureooms commented Jul 27, 2017

Sorry! I thought I had the latest version...

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