Check for .isPost?

Hi,
how do i check if a post is a post and not a page?

This works for me sort of
{{ if .Type | eq "post" }}
or
{{ if .Type | ne "page" }}
but not for the 404.html…

Have tried with .IsNode, but I do not get it on the 404 page.
Any var like .isPost as equivalent to .isPage?

Example example code for my site header.html

I would appreciate an answer, thanks!

Depends on what you mean by “post.” Are you talking about any individual page? Then you’d probably want {{.IsPage}}.

Otherwise, if you keep your posts in a directory (ie, contente/posts), this will work:

{{if eq .Section "posts"}}
YOUR STUFF HERE
{{end}}

You can also range through them…

{{range where .Site.Pages "Section" "==" "posts"}}
{{end}}

For me {{if eq .Section “post”}} does the trick. Not “posts”

{{if eq .Section "post"}}
YOUR STUFF HERE
{{end}}

The above will only target posts/pages inside the “content/post” directory.