.URL warning

My Hugo site had been running fine for awhile till a recent upgrade and then Hugo 0.55 began complaining about some things that have been deprecated.

I solved all of them but one

This one:
WARN 2019/04/27 21:02:17 Page’s .URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url.

I’m using .URL in two layout/partial files and don’t understand what I should do about this.

In my menu I’m using .URL and according to the error message I should be able to change it to .Params.url. Well this change goes from warnings to fatal errors like this:

execute of template failed: template: partials/menu.html:4:34: executing “partials/menu.html” at <.Params.url>: can’t evaluate field Params in type *navigation.MenuEntry

Permalink and RelPermalink also caused failures.

After checking the source of the generated html I see that the .URL was generating relative links. Which makes me think I want either .Params.url or RelPermalink.

Since I can’t make either seem to work for me the way I want them to, I don’t understand what to do about the deprecation of what works.

Help/Advice appreciated.

1 Like

The warning does not concern menus, I don’t think so.

For pages you should now use .Permalink or .RelPermalink. The suggestion to use .Params.url is only for users who needed to refer to a url key passed in the Front Matter.

2 Likes

if you used {{ .URL }} in range, change it to {{ .Permalink }}

1 Like