I have a news feature on a site where the landing page must list the sub news articles, this is working fine apart from the fact that the listing is also pulling in itself when building? Should I be creating the list a different way to:
{{ range where .Site.Pages “Type” “news” }} (Where type is the section)
Or is there a way to prevent the listing from pulling in itself?
Could you provide your directory structure which will help us with detail?
If you are pulling data in that format, It pulls up everything, may be you could use the .File.BaseFileName to exclude the current file or Section for the section.
content
---news
---newsarticle
---newsarticle
I then have my layouts within a theme
theme
---themename
---layouts
---list.html
---single.html
---li.html
Looking at the examples for list templates they seem to use .Data.Pages to list the content but when I try that it doesn’t render anything. This is my first time using Hugo so I am not sure what I am doing wrong.
Thanks,
newsarticle is a folder with an index.md file within, should they not be folders and just markdown files listed in the news content section? Because the news area is just an area within a larger site I needed a .md file for the news listing page to add content above the listing
The below is what I am using at the minute which is also pulling in itself because there is a .md file for the list page too
{{ range where .Site.Pages "Type" "news" }}
{{ .Render "single" }}
{{ end }}
Using
{{ range where .Data.Pages }}
{{ .Render "single" }}
{{ end }}