gokarna-theme / gokarna-hugo

A minimal opinionated theme for Hugo
https://gokarna-hugo.netlify.app
GNU General Public License v3.0
358 stars 140 forks source link

Tag links do not work when baseURL has a path prefix #129

Closed dchiquito closed 2 years ago

dchiquito commented 2 years ago

Resubmission of #126

My site is deployed at https://my.domain.com/blog/, rather than the more traditional https://my.domain.com. The tag links that appear under post titles incorrectly omit the /blog/ prefix, instead linking to https://my.domain.com/tags/whatever.

I solved this by adding my own post.html with this change:

        <ul class="post-tags">
        {{ range .Params.tags }}
            <!-- old
            <li class="post-tag"><a href="{{ "/tags/" | absLangURL }}{{ . | urlize }}">{{ . }}</a></li>
            -->
            <!-- new, prefixed / from "/tags/" removed -->
            <li class="post-tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{ . }}</a></li>
        {{ end }}
        </ul>

Interestingly, the Tags link from the nav header works correctly, even though I set it's URL to /tags/ in config.toml:

  [[menu.main]]
    name = "Tags"
    pre = "<span data-feather='tag'></span>"
    url = "/tags/"
    weight = 4

The examples at https://gohugo.io/functions/abslangurl/ also suggest that the prefixed / is not correct. I think the solution is to simply remove it.