'Eleventy: Add pagination only to blog posts

In Eleventy, I have a simple layout file that I'd like to use for most pages on my website, including the blog collection. I'd like the layout to only add my pagination partial when in a blog post.

My attempt below doesn't add the pagination partial to any post. I know I need to modify the if statement, but I don't know how. Everything works fine if I don't include the if statement, but pages not in the blog collection get some of the code from partial, which I don't want.

Any suggestions?

---
layout: layouts/base.njk
---
<article>
  <h1>{{ title }}</h1>
  {{ content | safe }}
</article>
{% if post in collections.blog %}
  {% include "partials/_pagination.njk" %}
{% endif %}


Solution 1:[1]

I got the answer from the Eleventy group on Discord:

---
layout: layouts/base.njk
---
<article>
  <h1>{{ title }}</h1>
  {{ content | safe }}
</article>
{% if "blog" in tags %}
  {% include "partials/_pagination.njk" %}
{% endif %}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nick J.