Having trouble targeting only posts

Sorry if this seems like a very basic question but i cannot figure out how to only target my posts. I would like to add social media meta tags to my header but i would like them to show up only if they are on a post page.

In a perfect world i would write something like this:
{{ if .IsPost }}

This should be a post


{{ end }}

Another thought i had was to target the url since my structure is something like this: www.someAwesomeSite.com/posts/some-awesome-blog-post/
I tried to use something suggested in another discussion such as this {{ if eq (relURL .URL) ("/" | safeHTML) }}HOME SWEET HOME{{ end }} but i could not get this to work.

Any thoughts or suggestions? Am i missing something simple? Any help would be greatly appreciated.

Solved {{ if eq .Section “posts” }} sorry for not reading/understanding the docs better.

1 Like

I think you are overthinking it, if you want some extra header to be added to all content of a type (in this case post), you can add it in the template for posts. You can have a different partial for post headers and reference it in the template.

Unless you want to add post specific social media tags in which case disregard my post.

In case of content type post it will be in layouts\post\single.html or themes\theme-name\layouts\post\single.html.

You can either mark a content as new type

  1. through it’s location in the content directory. For example everything in content\post is of type post or
  2. Add it to the front matter (in which case the location is overridden). For example everything with type: post in the frontmatter is of type post regardless of the location.