Skip to content

Commit

Permalink
Tags index page and sitemap for tags (#258)
Browse files Browse the repository at this point in the history
* Tags index page and sitemap for tags

* Observations of le4ker taken into account

* Conditional plural for "post" in tag list

---------

Co-authored-by: César Lizurey <[email protected]>
  • Loading branch information
cesar-lizurey and djcaesar9114 authored Oct 22, 2024
1 parent cb798b9 commit 770c0aa
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _layouts/tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ <h3 id="#{{ tag }}">#{{ tag }}</h3>
</div>
</div>
</div>

<h4><a href="{{site.baseurl}}/tags/">See other tags</a></h4>
</section>

{% include footer.html %}
Expand Down
35 changes: 35 additions & 0 deletions _layouts/tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- Tag Layout Start -->

<!doctype html>
<html lang="{{ site.lang }}">

{% include head.html %}

<body>
{% include navigation.html %}

<section class="container content-section text-center">
<div class="row">
<div class="col-md-10 col-md-offset-1 col-xs-10 col-xs-offset-1">
{% assign tag = page.title %}

<h3 id="#tags">#Tags</h3>
<ul style="list-style-type: none;display: flex;flex-direction: column;align-items: center;padding: 0">
{% assign sorted_tags = site.tags | sort %}
{% for tag in sorted_tags %}
<li>
<h4><a href="{{ site.baseurl }}/tags/{{ tag[0] }}.html">{{ tag[0] }}</a> ({{ tag[1].size }} post{% if tag[1].size > 1 %}s{% endif %})</h4>
</li>
{% endfor %}
</ul>
</div>
</div>
</section>

{% include footer.html %}

{% include js.html %}

</body>
</html>

7 changes: 7 additions & 0 deletions bin/generate_tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@
end
end
end

# Generate the tags.html page
puts("[+] Generating tags page")

File.open("#{TAGS_DIR}/index.html", 'w') do |f|
f.write("---\nlayout: tags\nsection-type: tags\nhas-comments: true\ntitle: Tags\nsitemap:\n priority: 1.0\n---\n## Tags")
end
7 changes: 7 additions & 0 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ layout: null
<priority>1.0</priority>
</url>
{% endfor %}
{% for tag in site.tags %}
<url>
<loc>{{ site.url }}{{ site.baseurl }}/tags/{{ tag[0] }}.html</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
{% endfor %}
</urlset>
9 changes: 9 additions & 0 deletions tags/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: tags
section-type: tags
has-comments: true
title: Tags
sitemap:
priority: 1.0
---
## Tags

0 comments on commit 770c0aa

Please sign in to comment.