Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags in alphabetical order #37

Open
redfish462 opened this issue Mar 28, 2021 · 1 comment
Open

Tags in alphabetical order #37

redfish462 opened this issue Mar 28, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request feature request

Comments

@redfish462
Copy link

Is your feature request related to a problem? Please describe.
Nope

Describe the solution you'd like
On the tags page, display the words in alphabetical order

Describe alternatives you've considered
No

Additional context
screenshot-tags

@piharpi piharpi added enhancement New feature or request feature request labels Apr 6, 2021
@piharpi piharpi self-assigned this Apr 6, 2021
@muzzug
Copy link

muzzug commented Feb 6, 2023

Hi.
On my site I edited the tags.html file by adding {% assign sorted_tags = site.tags | sort %} and replaced all site.tag with sorted_tags.

The resulting code looks like this:

---
title: Tags
permalink: /tags/
layout: page
excerpt: Sorted article by tags.
---

{% assign sorted_tags = site.tags | sort %}

<div class="archive-tags">
  <a class="tag-item" href="#">all</a>
  {%- for tag in sorted_tags -%} 
    {% capture name %}{{ tag | first }}{% endcapture %}
    <a class="tag-item" href="#{{name}}">{{ name }}</a> 
  {%- endfor -%}
</div>

{%- for tag in sorted_tags -%}
  {%- capture name -%}{{ tag | first }}{%- endcapture -%}
  <h2 id="{{ name }}">{{ name | upcase }}</h2>
  {%- for post in site.tags[name] -%}
    <article class="post-item" id="results-container">
      <span class="post-item-date">{{ post.date | date: "%b %d, %Y" }}</span>
      <h3 class="post-item-title">
        <a href="{{ post.url }}">{{ post.title | escape }}</a>
      </h3> 
    </article>
  {%- endfor -%}
{%- endfor -%}

It works great and my tags are sorted alphabetically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request
Projects
None yet
Development

No branches or pull requests

3 participants