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

"View All" categories & tags URL link broken #142

Closed
joakimvivas opened this issue Feb 20, 2018 · 4 comments

Comments

@joakimvivas
Copy link

commented Feb 20, 2018

Hi! The pages "Categories" & "Tags" when I pushed into the "View All" option the URL it's broken because the absolute URL it's not correct, example: "mydomain.comtags/tagname".

@joakimvivas

This comment has been minimized.

Copy link
Author

commented Feb 20, 2018

I changed the 22 line into the "terms.html" file on the theme directory with this command and the URL link now it's correct:

Origin
<a href="{{ $.Site.LanguagePrefix | absURL }}{{ $data.Plural }}/{{ $value.Name | urlize }}/" class="list-group-item view-all">

Changed
<a href="{{ $.Site.LanguagePrefix | absURL }}/{{ $data.Plural }}/{{ $value.Name | urlize }}/" class="list-group-item view-all">

@ulm0

This comment has been minimized.

Copy link

commented Mar 9, 2018

This happened to me as well, i'm running a i18n blog, and View all rendered http://domain.com/estags/topicsinspanish and http://domain.com/entags/topicsinenglish, after patching the terms.html file it renders properly http://domain.com/es/tags/topicsinspanish and http://domain.com/en/tags/topicsinenglish

@kaushalmodi

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2018

@joakimvivas That suggestion could end up in the link have double slashes if .Site.LanguagePrefix already contains a string with a trailing /.

Example: If I have baseURL set to https://example.com/, AND if I use only the default single "en" language, .Site.LanguagePrefix will return https://example.com/. So your suggestion will end up with something like https://example.com//tags/...

Solution

Instead of manually always adding that /, we can do:

.Site.LanguagePrefix | absURL | replaceRE "[^/]$" "${0}/"

, which basically adds the / as suffix if it doesn't already exist.

Tests

{{ printf "%s" ("foo" | absURL | replaceRE "[^/]$" "${0}/") | safeHTML }}  {{/* returns http://localhost:1313/foo/ */}}

{{ printf "%s" ("foo/" | absURL | replaceRE "[^/]$" "${0}/") | safeHTML }} {{/* also returns http://localhost:1313/foo/ */}}
martignoni added a commit to moodlebox/hugo-moodlebox-theme that referenced this issue May 31, 2018
@halogenica

This comment has been minimized.

Copy link
Owner

commented Nov 8, 2018

Thanks! This should have been fixed; if it still occurs please let me know.

@halogenica halogenica closed this Nov 8, 2018
VincentTam added a commit to VincentTam/beautifulhugo that referenced this issue Nov 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.