# How to list all posts for any given tag?

**URL:** <https://talk.jekyllrb.com/t/how-to-list-all-posts-for-any-given-tag/1402>\
**Category:** Help\
**Created:** [January 25, 2018, 4:36pm UTC](https://talk.jekyllrb.com/t/how-to-list-all-posts-for-any-given-tag/1402 "2018-01-25T16:36:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![koahv](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/koahv/32/740_2.png) [@koahv](https://talk.jekyllrb.com/u/koahv)\
**Post date:** [January 25, 2018, 4:36pm UTC](https://talk.jekyllrb.com/t/how-to-list-all-posts-for-any-given-tag/1402/1 "2018-01-25T16:36:49Z")

</div>

This is my code from post.html in the \_layouts directory

```
<ul class="tags">

	{% for tag in page.tags %}
		
		<li><a href="/tags#{{ tag }}" class="tag">{{ tag }}</a></li>

		{% for post in site.tags.tag %}

			<ul class="taglinks">

				<li><a href="{{ post.url }}">{{ post.title }}</a></li>

			</ul>

		{% endfor %}

	{% endfor %}
</ul>

```

But it doesn’t work - the post links aren’t written to each post.

Thanks in advance!

Al

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [January 25, 2018, 5:10pm UTC](https://talk.jekyllrb.com/t/how-to-list-all-posts-for-any-given-tag/1402/2 "2018-01-25T17:10:12Z")

</div>

you want a list of each tag, with that tags posts below it?  
here is what I have to do that, there is some other stuff going on but I’ll leave it in there. I haven’t built this site in quite a while but it should still work.

this is this page: [http://ephotopros.com/tags/](http://ephotopros.com/tags/)

```auto

{% assign sorted_tags = site.tags | sort %}
{% for tag in sorted_tags %}
{% assign vids = tag[1] | sort %}

{% if vids != empty %}

  <h2 id="{{tag[0] | uri_escape | downcase}}">{{tag[0]}}</H2>
     <p>
      {% for p in vids %}
     <a href="/{{p.type | downcase}}/"><img src="/assets/img/{{p.type | downcase}}.png" alt="{{p.type}}" title="{{p.type}}"/></a> <a href="{{ p.url }}">{{ p.title }}</a> ({{p.type}}/{{p.category}}) &raquo; <span class="entry-date"><time datetime="{{ p.date | date_to_xmlschema }}" itemprop="datePublished">{{ p.date | date: "%B %d, %Y" }}</time></span>
     <br />
      {% endfor %}
    </p>
  
{% endif %}

{% endfor %}

```

---

<div class="post-metadata">

**Author:** ![koahv](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/koahv/32/740_2.png) [@koahv](https://talk.jekyllrb.com/u/koahv)\
**Post date:** [January 26, 2018, 3:08pm UTC](https://talk.jekyllrb.com/t/how-to-list-all-posts-for-any-given-tag/1402/3 "2018-01-26T15:08:53Z")

</div>

Thank you rdyar.

I have a [tags page](https://data-1.science/tags/) already.

I would like each post [(example)](https://data-1.science/technology/2017/07/27/first-molecules-discovered-by-next-generation-artificial-intelligence-to-be-developed-into-drugs.html) to list site posts for each of those tags it contains.

Thanks again,

Al
