<ul class="stats">
    {{ if isset .Params "categories" }}
        {{ $categoryCount := (len .Params.categories) }}

        <!--
            Set the title before displaying the categories associated with this post.
            The title will use the variables from the Categories menu set in the Config.
            If the Categories menu was not set then use the default values instead.
        -->
        {{ if ge $categoryCount 1 }}
            <li>
                {{ $categoryMenu := (where .Site.Menus.main "Name" "Categories") }}
                {{ if ne (len $categoryMenu) 0 }}
                    {{ $categoryMenu := index $categoryMenu 0 }}

                    {{ $.Scratch.Set "categoryUrl" $categoryMenu.URL }}

                    {{ with $categoryMenu.Identifier }}
                        <i class="{{ . }}">&nbsp;</i>
                    {{ end }}

                    {{ if gt $categoryCount 1 }}
                        {{ $categoryMenu.Name }}
                    {{ else }}
                        {{ $categoryMenu.Name | singularize }}
                    {{ end }}
                {{ else }}
                    {{ $.Scratch.Set "categoryUrl" "/categories/" }}

                    {{ if gt $categoryCount 1 }}
                        Categories
                    {{ else }}
                        Category
                    {{ end }}
                {{ end }}
            </li>
        {{ end }}
    {{ end }}

    <!-- Display the categories associated with this post -->
    {{ range .Params.categories }}
        <li><a href='{{ add ($.Scratch.Get "categoryUrl") . | urlize }}'>{{ . }}</a></li>
    {{ end }}
</ul>

<ul class="stats">
    {{ if isset .Params "categories" }}
        {{ $categoryCount := (len .Params.categories) }}

        <!--
            Set the title before displaying the categories associated with this post.
            The title will use the variables from the Categories menu set in the Config.
            If the Categories menu was not set then use the default values instead.
        -->
        {{ if ge $categoryCount 1 }}
            <li>
                {{ $categoryMenu := (where .Site.Menus.main "Name" "Categories") }}
                {{ if ne (len $categoryMenu) 0 }}
                    {{ $categoryMenu := index $categoryMenu 0 }}

                    {{ $.Scratch.Set "categoryUrl" $categoryMenu.URL }}

                    <!-- Ensure that there is a trailing '/' in the category Url -->
                    {{ if ne (substr ($.Scratch.Get "categoryUrl") (sub (len ($.Scratch.Get "categoryUrl")) 1)) "/" }}
                        {{ $.Scratch.Set "categoryUrl" (add ($.Scratch.Get "categoryUrl") "/") }}
                    {{ end }}

                    {{ with $categoryMenu.Identifier }}
                        <i class="{{ . }}">&nbsp;</i>
                    {{ end }}

                    {{ if gt $categoryCount 1 }}
                        {{ $categoryMenu.Name }}
                    {{ else }}
                        {{ $categoryMenu.Name | singularize }}
                    {{ end }}
                {{ else }}
                    {{ $.Scratch.Set "categoryUrl" "/categories/" }}

                    {{ if gt $categoryCount 1 }}
                        Categories
                    {{ else }}
                        Category
                    {{ end }}
                {{ end }}
            </li>
        {{ end }}
    {{ end }}

    <!-- Display the categories associated with this post -->
    {{ range .Params.categories }}
        <li><a href='{{ add ($.Scratch.Get "categoryUrl") . | urlize }}'>{{ . }}</a></li>
    {{ end }}
</ul>

Fix category url in category-footer.html
Fix category url in category-footer.html

Ensure that there is a trailing '/' in the category URL when using the
url defined for the menu item "Categories". Without this the template
produces invalid urls for the category links in the footer of the post
if the user has defined a menu item named "Categories" without a
trailing slash (as in the example page).
