Skip to content
colynb edited this page Nov 17, 2013 · 4 revisions

As of version 0.2.0, you can now create tag pages.

Create a tag page

Just create a page like you normally would for one of your tags in your src folder.

For instance, if I wanted to create a page for the tag examples then I would create a file:

src/docs/examples.html

Then in the page, loop over all the posts with the tag "examples" with the new query method getPostsByTag('examples'):

---
layout: page
title: Examples
path: /tags/examples.html
type: page
created: '2013-11-16T19:28:35-07:00'
---

{% for post in collection.getPostsByTag('examples') %}
<section class="post">
  <header class="post-header">
    <h2 class="post-title"><a href="{{ post.get('path') }}">{{ post.get('title') }}</a></h2>
  </header>
  <p class="post-meta">
    By <span class="post-author">{{ post.get('author')['name'] }}</span> under 
    {% for tag in post.get('tags') %}
      <a class="post-tag" href="/tags/{{ tag }}.html">{{ tag }}</a>
    {% endfor %}
  </p>
  <p class="post-description">
    {{ post.get('snippet') }}
  </p>
</section>
{% endfor %}

Create a tag page the lazy way

Or use the built in generator to do all of that for you.

$ yo go-static:tag mytag
Clone this wiki locally