Alphabetical sorting with headings


#1

Hi all!

Is alphabetical ordering with headings possible—e.g. for a large tags overview?

<h2>3</h2>
<ul>
  <li>3D</li>
</ul>

<h2>A</h2>
<ul>
  <li>Accessibility</li>
  <li>App</li>
</ul>

<h2>H</h2>
<ul>
  <li>Hugo</li>
</ul>

Thank you!


#2

If I’m understanding correctly, you could use GroupBy, then print the first letter of the Key


#3

See https://gohugo.io/templates/taxonomy-templates/#order-alphabetically-example

Also see: https://github.com/gohugoio/hugo/issues/5719 for how we’re going to improve the above in the next Hugo version.


#4

Thank you!

I played a bit. Alphabetical ordering is no problem. But it seems quite tricky (for me) to get the first letter of each group of tags–and only if that group exists.

It would be great if there was an out of the box solution, bep.