Tag your pages. Show all pages with that tag.
A Phile plugin. Project home.
composer require siezi/phile-tags;
$config['plugins']['siezi\\phileTags'] = ['active' => true];
Add a new Tags
attribute to the page meta:
/*
Title: My First Blog Post
Tags: js, javascript, php
*/
The tags are available as meta.tags_array
in the template.
To show tags for a page and link them to the tag-page:
{% if meta.tags_array is not empty %}
{% for tag in meta.tags_array %}
<a href="{{ base_url }}/tag/{{ tag }}">
#{{ tag }}
</a>
{% endfor %}
{% endif %}
Create a new template "tag.html" in themes/<your_theme>/tag.html
. It is used to show all pages having a particular tag when calling the URL /tag/<tag-name>
.
<!DOCTYPE html>
<head>
<title>{{ meta.title }}</title>
</head>
<body>
<h2>Posts tagged #{{ current_tag }}:</h2>
{% for page in pages %}
{% if page.meta.tags_array and current_tag in page.meta.tags_array %}
<div class="post">
<h2><a href="{{ base_url }}/{{ page.url }}">{{ page.meta.title }}</a></h2>
<div class="excerpt">{{ page.content }}</div>
<span class="meta-tags">Tags:
{% for tag in page.meta.tags_array %}
<a href="{{ base_url }}/tag/{{ tag }}">#{{ tag }}</a>
{% endfor %}
</span>
</div>
{% endif %}
{% endfor %}
</body>
</html>
See the config.php
.