I have a feeling this is an almost trivial question…
I want to create a page like the layouts/index.html, which in my case uses a partial for each project content file (the theme is ~HugoMDL). I don’t want to change the main front page, but I want to create a page that checks/shows the completeness of the metadata for each project I have.
To test it, I modified the layouts/index.html and it works like I want to, but how do I get this page next to the normal front-page index.html as a separate page called “index2.html” or “completeness.html” and then somehow link to that from some about page or whatever?
A page is generated, but I don’t see the metadata for all the project pages. Do I need some sort of other “Path” to the page variables to get the frontmatter data from the project files?
In the single.html I have this to loop over the project files and print a table row for each project with all the relevant metadata
{{ range first $.Site.Params.frontpageposts .Data.Pages }}
{{ if eq .Type "project" }}{{ .Render "project-card-status" }} {{ end }}
{{ end }}
The project1 files reside in content/project/project1.md
To help you construct it I need to ask how have you arranged your content?
Are all the pages you want to render under the section /projects/?
Do you want to render all of them or only the ones with the above parameter?
frontpageposts = 40 #number of post cards to display on frontpage +1
(it’s 40 to make sure all are listed, as there are much less than 40 projects)
I guess the original range worked, because it was the toplevel index.html with access to the .Data.Pages “array” of all pages. Can I access this same array from the new single.html?
As I understand it, range can loop over a bunch of things, with generates a single instance to work with…
So I guess I need something with range…
When I try your suggestion I get:
WARN 2017/08/04 12:46:46 .Render only available for regular pages, not for of kind "section". You probably meant .Site.RegularPages and not.Site.Pages.
among the messages from hugo.
When I try range it gets worse.
The docs aren’t very clear to me about what comes out of .GetPage, except common sense says: it’s a single object, otherwise it would have said: .GetPages, which is not a known function (yet? )
No. .GetPage gets both regular pages and list pages. Everything is a Page in Hugo these days.
Also forget about range when using .GetPage it’s a different function.
Now regarding the .Render error what is inside this template? Where is it located?
You should be able to get all the posts from your projects section on a regular page and render them as you please using another way.
OR
Since you said that you got this working earlier in your index.html under /layouts/ create the following template /layouts/sections/projects/index.html copy the contents of your /layouts/_default/list.html and then modify it with the code you got working earlier. Your projects will then be available on your section’s list page i.e /projects/