.URL deprecated but still in use and working in 0.115.2

I know that .URL been depreciated. For some time Hugo thrown a warning to replace .URL with use of .Permalink etc.

Interesting discussion come up when Frank from tekki-tipps.de mentioned that .URL is not documented in Hugo documents anymore, but the below code is still working.

The general advise was to replace .URL with .RelPermalink or .Permalink, however in below instance is not working, but .URL is. Can somebody advise about the uses of .URL.

{{ $href := .Permalink }}
    {{ with $.Paginator }}
      {{ if gt .PageNumber 1 }}
      {{ $href = .URL | absURL }}
      {{ end }}
  {{ end }}
  <link rel="canonical" href="{{ $href }}">

Related .Permalink doesn't contain the `/page/:number` part in paginated list templates · Issue #4507 · gohugoio/hugo · GitHub

.Page.URL was removed. Use .Page.RelPermalink instead.

The .URL methods for pagination (link to current pager) and menu entries are something different.

https://gohugo.io/templates/pagination/#build-the-navigation
https://gohugo.io/variables/menus/#variables

1 Like

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