{% capture tags %} {% if post %} {% for tag in post.tags %} {% unless forloop.last %} {% endunless %} {% endfor %} {% else %} {% for tag in page.tags %} {% unless forloop.last %} {% endunless %} {% endfor %} {% endif %} {% endcapture %} {{ tags }}