Range .Pages from single template

OK.

On my end the URL http://localhost:1313/posts/16-medical-benefits-marijuana/ threw a 404 locally.

I had to delete draft = "true" from the post’s front matter.

So here is why that page got a 404 on Netlify. Drafts are not published.

As for your missing loop:

First, you do not need the dollar sign ($). You would use that if you where within a shortcode to go higher up.

Second .Data.Pages is for list pages not single pages.

You should use .Site.Pages for a single page template to render other pages.

[ Not entirely unrelated note. Hey @kaushalmodi (thought you wanted to see this) here is a use case where simply using {{ range .Pages }} doesn’t return anything only .Site.Pages returns results ]

But anyway @jnthnclrk are you sure you want to display post permalinks in your header? You will need 2 different headers with such a design. One for single pages and one for lists. Not very DRY (Don’t Repeat Yourself)

Also see related topic about .Data.Pages vs .Site.Pages from a single page template:

1 Like