Skip to content
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 · 10 comments · Fixed by #2913
Closed

Paginator URL encoding problem #2177

RNAer opened this issue May 31, 2016 · 10 comments · Fixed by #2913
Assignees
Milestone

Comments

@RNAer
Copy link

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 URL encoding problem Paginator URL encoding problem May 31, 2016
@bep bep added the Bug label May 31, 2016
@bep
Copy link
Member

bep commented May 31, 2016

What is the easiest way to fix this? Thanks!

A pull request would be fastest.

@RNAer
Copy link
Author

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
Copy link
Contributor

ks888 commented Jul 24, 2016

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

@Funatiker
Copy link

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
Copy link

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
Copy link

@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
Copy link

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 as completed in #2913 Jan 8, 2017
bep added a commit that referenced this issue Jan 8, 2017
@marcliberatore
Copy link

Thank very much @bep!

@bomzj
Copy link

bomzj commented Sep 3, 2018

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants