Since I updated to latest version, I’ve had some issues.
I see the same pages in sections list pages as I do in tags, there doesn’t seem to be a difference. For example, /tags/salvia/ is only supposed to show 3 pages with the #salvia tag, but I’m getting all the pages somehow.
https://dev.psychedelicsdaily.com/tags/salvia/ I’m supposed to see only 3 pages listed here
For reference: The Salvia Vault - Using Psychedelics Daily for a happy & healthy life it shows the correct pages here in the list
https://dev.psychedelicsdaily.com/psychedelics/lsd/ should only show pages from that section
https://dev.psychedelicsdaily.com/psychedelics/salvia/ should only show pages from that section
But that is not what I’m getting. Same happens when you go to /psychedelics/* I expect to see only the pages in that section, but I see all the pages.
There’s probably something I have misunderstood.
Here is the repo: https://gitlab.com/hashborgir/psychedelicsdaily.com-hugo.git in the hugo-dev branch
I started Hugo when I barely understood it, so I ended up basically making all my changes in the /themes/ directory directly.
Please advise.
Update: Someone on IRC helped me out finding this: Page lists broken in various theme demos in 0.57.0 · Issue #678 · gohugoio/hugoThemes · GitHub
Perhaps this is causing me issues. Any insight?
I’ve set
[[params]]
mainSections = ["blog", "psychedelics", "news"]
in my config.
Then I’ve added
{{ $paginator := .Paginate (where .Site.RegularPages "Type" "in" site.Params.mainSections) }}
And now I get no pages in my list. I don’t get any errors, and a successful build, but no pages in the lists.
{{ $paginator := .Paginate (where .Data.Pages "Type" "in" .Site.Params.mainSections) }}
After much trial and error, this seems to fix the tags.
I’ve read all the issues regarding this, as well as the forum post and etc. and I still don’t understand what all this means.
Fantastic. Things work as expected now. I just need to understand now that why is the switching to .Data.Pages from .Site.RegularPages etc.?
Could someone kindly shed light on this?
Thank you.
Have a read here for the differences between .Pages
: https://gohugo.io/variables/page/#pages
I understand the Page variables. I wonder why .Site.RegularPages doesn’t work (no results) and .Data.Pages does work, even though I’m not using the /data/ directory.
That part is confusing to me.
Also, the documentation page says to use site.Params.mainSections
but I am aware that site vars begin with .Site.*
so I’m unsure whether that was causing any issues or was a typo on the documentation.
Could you maybe tell me why .Data.Pages is giving me a result while .Site.RegularPages etc. does not?
Try these in your list.html
template:
<h1>.Site.RegularPages</h1>
<ul>
{{ range .Site.RegularPages }}
<li>{{.}}</li>
{{ end }}
</ul>
<hr>
<h1>.Data.Pages</h1>
<ul>
{{ range .Data.Pages }}
<li>{{.}}</li>
{{ end }}
</ul>
<h1>.Pages</h1>
<ul>
{{ range .Pages }}
<li>{{.}}</li>
{{ end }}
</ul>
.Data.Pages
and .Pages
should return the same list of Pages because .Pages
is an alias to .Data.Pages
. That’s in the docs I link to above.
In this context, .Data[.Pages]
has nothing to do with the /data
folder in your project; the /data
folder is in .Site.Data
site
is the same as .Site
: https://gohugo.io/news/0.53-relnotes/
So, if you have the below structure:
content
├── clouds
│ ├── _index.md
│ ├── cirrus.md
│ └── nimbus.md
├── colors
│ ├── _index.md
│ ├── blue.md
│ ├── red.md
│ └── yellow.md
...
When you are in yoursite.com/clouds/
, you will have:
.Site.RegularPages:
clouds/cirrus.md
clouds/nimbus.md
colors/blue.md
colors/red.md
colors/yellow.md
.Pages:
clouds/cirrus.md
clouds/nimbus.md
When you are in /tags/
, you will have
.Site.RegularPages:
[same as above]
.Pages:
tags/ipsum
tags/lorem
When you are in /tags/lorem/
, you will get the pages with tag lorem
:
.Site.RegularPages:
[same as above]
.Pages:
colors/blue.md
clouds/nimbus.md
1 Like
system
Closed
April 26, 2020, 5:31am
8
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.