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 #126

Closed dchiquito closed 2 years ago

dchiquito commented 2 years ago

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
yashmehrotra commented 2 years ago

@dchiquito Which version of the theme are you using ? This was fixed by a change which was pushed a few months ago (0fe9d215). Try updating your code and re-raise this issue if it still persists

dchiquito commented 2 years ago

@yashmehrotra I'm using the most recent version. https://gohugo.io/functions/abslangurl/ suggests that the argument should not have the prefixed /. I will resubmit the issue.

jamesericdavidson commented 2 years ago

Thanks, Daniel.

I'm no designer. I can make something functional, and that's about it.

I agree about making this an optional feature. If this functionality is wanted upstream, I'm happy to put the work into solving the weight and default sort problem.

Regards, James Davidson

-------- Original Message -------- On 22 Sept 2022, 21:02, Daniel Chiquito wrote:

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 }}

<

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

=

"

"

url

=

"

/tags/

"

weight

=

4

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>