absLangURL isn't working

Hi I found that absLangURL isn’t working. It doesn’t output the full path.

Here’s the hugo code:

{{ range .Site.Menus.main -}}
          <li>
            <a href="{{.URL | absLangURL}}">{{.Name}}</a>
          </li>
{{ end -}}

and here’s the menu:

[menu]
  [[languages.en.menu.main]]
    identifier = "Item"
    name = "Item"
    url = "/page-1"
    weight = 10
  [[languages.en.menu.main]]
    identifier = "Item-2"
    name = "Item 2"
    url = "#contact"
    weight = 20
  [[languages.de.menu.main]]
    identifier = "Item"
    name = "Item"
    url = "/page-1"
    weight = 10
  [[languages.de.menu.main]]
    identifier = "Item-2"
    name = "Item 2"
    url = "#contact"
    weight = 20

I expect to get domain.com/page-1 or domain.com/de/page-1 but get only domain.com/
but if I use reLangURL

    {{ range .Site.Menus.main -}}
          <li>
            <a href="{{.URL | reLangURL}}">{{.Name}}</a>
          </li>
    {{end}}

I get /page-1 which is correct.

  1. What is your Hugo version
  2. Can you recheck your last code sample? There is no reLangURL. Just in case you typed it instead of copying it.

Other than that:

  • absURL is absolute from site root
  • relURL is relative from the current page.

Assuming you are on /some/page/ then a link to /some/other/page/ should come out as /some/other/page/ in absURL and ../other/page in relURL.

I wouldn’t think this is a bug. I would expect domain-less URLs for these links. You also want it to be that way, because you can migrate easier to a new topleveldomain.