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

Paginator URL encoding problem #2177

Closed
RNAer opened this Issue May 31, 2016 · 9 comments

Comments

Projects
None yet
6 participants
@RNAer

RNAer commented May 31, 2016

I use the following to paginate my posts:

<nav class="pagination">
        {{if .HasPrev}}
             <a class="newer-posts" href="{{ .Prev.URL }}">&larr; Newer</a>
        {{else}}
             <a class="newer-posts" disabled="disabled" href="#">&larr; Newer</a>
        {{end}}
        <span class="page-number">Page {{ .PageNumber }} of {{.TotalPages}}</span>
        {{if .HasNext}}
            <a class="older-posts" href="{{ .Next.URL }}">Older &rarr;</a>
        {{else}}
             <a class="newer-posts" disabled="disabled" href="#">Older &rarr;</a>
        {{end}}
</nav>

I have chinese characters "阅读" in the tag, which is encoded as "%e9%98%85%e8%af%bb". Looks like Hugo encodes it and strips "%" to generate the URL, because .Next.URL returns this url http://localhost:1313/tags/e99885e8afbb/page/2/. This causes problem, for the directory structure is still in Chinese character, resulting in a 404 error.

Is this a bug? What is the easiest way to fix this? Thanks!

@bep bep changed the title from URL encoding problem to Paginator URL encoding problem May 31, 2016

@bep bep added the Bug label May 31, 2016

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep May 31, 2016

Member

What is the easiest way to fix this? Thanks!

A pull request would be fastest.

Member

bep commented May 31, 2016

What is the easiest way to fix this? Thanks!

A pull request would be fastest.

@RNAer

This comment has been minimized.

Show comment
Hide comment
@RNAer

RNAer May 31, 2016

Currently Hugo doesn't support ulr decoding and encoding? I am a newbie to
golang. It might take me a while to do that, although I image this should
be an easy fix.

On Tue, May 31, 2016 at 12:56 AM, Bjørn Erik Pedersen <
notifications@github.com> wrote:

What is the easiest way to fix this? Thanks!

A pull request would be fastest.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2177 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AA9CeODnF0qyLYH0epnMt0phRUKnScCWks5qG-mkgaJpZM4IqNC9
.

RNAer commented May 31, 2016

Currently Hugo doesn't support ulr decoding and encoding? I am a newbie to
golang. It might take me a while to do that, although I image this should
be an easy fix.

On Tue, May 31, 2016 at 12:56 AM, Bjørn Erik Pedersen <
notifications@github.com> wrote:

What is the easiest way to fix this? Thanks!

A pull request would be fastest.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#2177 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AA9CeODnF0qyLYH0epnMt0phRUKnScCWks5qG-mkgaJpZM4IqNC9
.

@ks888

This comment has been minimized.

Show comment
Hide comment
@ks888

ks888 Jul 24, 2016

Contributor

I can't reproduce the bug. Hugo version and your config file might be helpful.

Contributor

ks888 commented Jul 24, 2016

I can't reproduce the bug. Hugo version and your config file might be helpful.

@Funatiker

This comment has been minimized.

Show comment
Hide comment
@Funatiker

Funatiker Jan 2, 2017

Not sure whether that is related but if my base URL contains the tilde symbol (~), then it won't show in the paginator-Link which makes the pages 404.

Funatiker commented Jan 2, 2017

Not sure whether that is related but if my base URL contains the tilde symbol (~), then it won't show in the paginator-Link which makes the pages 404.

@marcliberatore

This comment has been minimized.

Show comment
Hide comment
@marcliberatore

marcliberatore Jan 4, 2017

I have the same issue as Funatiker with Hugo Static Site Generator v0.18 BuildDate: 2016-12-19T14:43:00-05:00 and baseurl = "http://people.cs.umass.edu/~liberato/home/" in my config; the ~ is stripped from the paginator's Next and Previous URLs, but not from other URLs.

marcliberatore commented Jan 4, 2017

I have the same issue as Funatiker with Hugo Static Site Generator v0.18 BuildDate: 2016-12-19T14:43:00-05:00 and baseurl = "http://people.cs.umass.edu/~liberato/home/" in my config; the ~ is stripped from the paginator's Next and Previous URLs, but not from other URLs.

@Funatiker

This comment has been minimized.

Show comment
Hide comment
@Funatiker

Funatiker Jan 4, 2017

@marcliberatore maybe I should add some more information on that:

$ hugo version
Hugo Static Site Generator v0.18 BuildDate: 2016-12-19T15:44:47+01:00

(using the .deb-Package that was released here on GitHub)

I'm using the theme https://github.com/jnjosh/internet-weblog . My wild guess (without knowing much about hugo's code) is that the problem occurs somewhere around the function URLizeAndPrep that is used by newPaginationURLFactory.

Funatiker commented Jan 4, 2017

@marcliberatore maybe I should add some more information on that:

$ hugo version
Hugo Static Site Generator v0.18 BuildDate: 2016-12-19T15:44:47+01:00

(using the .deb-Package that was released here on GitHub)

I'm using the theme https://github.com/jnjosh/internet-weblog . My wild guess (without knowing much about hugo's code) is that the problem occurs somewhere around the function URLizeAndPrep that is used by newPaginationURLFactory.

@marcliberatore

This comment has been minimized.

Show comment
Hide comment
@marcliberatore

marcliberatore Jan 5, 2017

I've created a small site that should enable reproducing this issue. Clone https://github.com/marcliberatore/disappearing-tilde, use hugo v0.18 in server mode to render it, and check the "Older" button's URL. It's missing a tilde (at least for me).

marcliberatore commented Jan 5, 2017

I've created a small site that should enable reproducing this issue. Clone https://github.com/marcliberatore/disappearing-tilde, use hugo v0.18 in server mode to render it, and check the "Older" button's URL. It's missing a tilde (at least for me).

@bep bep added this to the v0.19 milestone Jan 7, 2017

@bep bep self-assigned this Jan 7, 2017

bep added a commit that referenced this issue Jan 7, 2017

bep added a commit to bep/hugo that referenced this issue Jan 8, 2017

@bep bep closed this in #2913 Jan 8, 2017

bep added a commit that referenced this issue Jan 8, 2017

@marcliberatore

This comment has been minimized.

Show comment
Hide comment
@marcliberatore

marcliberatore Jan 9, 2017

Thank very much @bep!

marcliberatore commented Jan 9, 2017

Thank very much @bep!

@bomzj

This comment has been minimized.

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