How to list all posts for any given tag?


#1

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


#2

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/


{% 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 %}

#3

Thank you rdyar.

I have a tags page already.

I would like each post (example) to list site posts for each of those tags it contains.

Thanks again,

Al