Generate numbered list in a template

Can Hugo Generate a custom numbered list in a template? I want each of the five posts below to have an incremental number before them (1-5) without the decimal point (1 not 1.)

{{ range site.RegularPages | first 5 }}
<ul >
          <a href="{{ .Permalink }}">
            <span> The list numbers go here </span>
            <h3 >{{ .Title }}</h3>
{{- end }}

go to html OL


I tried that before posting. But Hugo templates do not generate list numbers by default.

Yes, change the template.

You can make a copy to list5.html, change it and refer to it with layout=“list5” in frontmatter.

If it helps, I am trying to replicate the “latest business news” section on BBC’s sidebar


The class name in the example above is “custom”. If you want to apply this to markdown:

1. Foo
1. Bar
1. Baz
{.custom}  # or {class=custom}

Requires this in site config:

block = true  # default is false

I needed to apply it to the sidebar partial. But the link you shared has the solution.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.