Getting warning on .File.TranslationBaseName after updating my Hugo

My computer recently crashed and I had to install a new version of hugo.
Previously I was able to build my site with no warnings but now I get 3 warnings:

WARN 2020/11/15 09:05:43 .File.TranslationBaseName on zero object. Wrap it in if or with: {{ with .File }}{{ .TranslationBaseName }}{{ end }}

WARN 2020/11/15 09:05:43 Page.GetParam is deprecated and will be removed in a future release. Use .Param or .Params.myParam.

WARN 2020/11/15 09:05:43 Page.LanguagePrefix is deprecated and will be removed in a future release. Use .Site.LanguagePrefix.

For the first warning, I search and it is only used inside the sitemap.xml as:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{{ $baseURL := .Site.BaseURL }}
  {{ range sort .Data.Pages }}
  <url>
    <loc>{{ $baseURL }}{{ .LanguagePrefix }}/#{{ .File.TranslationBaseName }}</loc>{{ if not .Lastmod.IsZero }}
    <lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
    <changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
    <priority>{{ .Sitemap.Priority }}</priority>{{ end }}
  </url>
  {{ end }}
</urlset>

Can someone please tell me how do I need to change this as I do not know the GO language?

Also, any help on the 2nd and 3rd warnings will be really appreciated.

It states what you have to do :slight_smile:

WARN 2020/11/15 09:05:43 .File.TranslationBaseName on zero object. Wrap it in if or with: {{ with .File }}{{ .TranslationBaseName }}{{ end }}

<loc>{{ $baseURL }}{{ .LanguagePrefix }}/#{{ with .File }}{{ .TranslationBaseName }}{{ end }}</loc>{{ if not .Lastmod.IsZero }}

WARN 2020/11/15 09:05:43 Page.GetParam is deprecated and will be removed in a future release. Use .Param or .Params.myParam.

Look for Page.GetParam in your other templates and exchange (don’t forget the dot in the beginning of the new command).

WARN 2020/11/15 09:05:43 Page.LanguagePrefix is deprecated and will be removed in a future release. Use .Site.LanguagePrefix.

<loc>{{ $baseURL }}{{ .Site.LanguagePrefix }}/#{{ with .File }}{{ .TranslationBaseName }}{{ end }}</loc>{{ if not .Lastmod.IsZero }}

Best is you use an advanced text editor or IDE that can do search and replace over all layout files. The second warning needs a more careful look at what you replace, but number 1 and 3 can be just searched and replaced.

1 Like

@davidsneighbour thanks so much for the help. I did what you suggested and all warnings are gone. I appreciate your help.

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