GAZ082
February 7, 2022, 10:46pm
1
So, since I upgraded from 0.5x to 0.92 my links to tags that filter out posts do not work, ie:
http://localhost:1313/tags/tools/
Still shows all posts.
This is the code I use to generate the URL:
<div class="tags">
<i name="hint" class="fas fa-tags"></i>
{{ with .Params.tags }}
{{ range . }}
{{ $href := print (absURL "tags/") (urlize .) }}
<a href="{{ $href }}">#{{ . }}</a><span class="space"></span>
{{ end }}
{{ end }}
</div>
The links are properly generated, but again, using them has no effect, all posts are displayed.
My config:
{
"baseURL": "https://xx.xx/",
"languageCode": "en-us",
"title": "xx",
"enableInlineShortcodes": true,
"googleAnalytics": "UA-x-1",
"summaryLength": 20,
"paginate": 4,
"permalinks": {
"post": "/:slug/",
"fixed": "/:slug/"
},
"params": {
"author": "Gabriel",
"dateFormat": "2006-01-02",
"twitterURL": "xx",
"twitterTXT": "@xx",
"subTitle": "I'm Gabriel"
},
"menu": {
"main": [
{
"name": "Home",
"url": "/",
"weight": 1
},
{
"name": "About Me",
"url": "/about-me",
"weight": 2
}
]
}
}
Which template is being used to render your term pages?
What is the range statement within that template?
GAZ082
February 7, 2022, 11:18pm
3
Hey, My own template.
Check in this part of the code I shared:
{ with .Params.tags }}
{{ range . }
Yeah, that doesnβt help. What would help is seeing your entire project.
See https://discourse.gohugo.io/t/requesting-help/9132 .
Let us see your code
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone
on your repo, then run hugo server
in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
If you canβt share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem youβre experiencing.
GAZ082
February 10, 2022, 2:48am
5
You have one template for listing pages: layouts/_default/list.html
That template iterates through:
where .Site.RegularPages.ByDate.Reverse "Section" "post"`
So you are getting the same results regardless of whether you are viewing a section, taxonomy, or term page.
Create some new layouts:
layouts/
βββ _default/
βββ baseof.html
βββ list.html
βββ single.html
βββ taxonomy.html <-- new
βββ terms.html <-- new
And in the new ones, just iterate over .Pages
1 Like
GAZ082
February 11, 2022, 1:09pm
7
Thanks Joe! Creating a Taxonomy fixed the issue (for reference, made just like a list.html and paginated through .Pages).
One last question, when are terms used?
A taxonomy template list the terms associated with a given taxonomy.
A terms template lists the pages associated with a particular term in a given taxonomy.
system
Closed
February 13, 2022, 1:18pm
9
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.