Updating an older site with latest Hugo

Hello! I’m trying to update a site that was built ca 2019 The repo can be found here: GitHub - fraguada/elizabethbiggerdotcom: Hugo website files for Elizabeth Bigger

I am on a newly wiped laptop and installed Hugo v0.107.0, then ran hugo to see what would happen. I get the following errors:

Start building sites … 
hugo v0.107.0+extended darwin/amd64 BuildDate=unknown
ERROR 2022/12/05 23:31:42 render of "page" failed: "/Users/.../Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/_default/baseof.html:73:12": execute of template failed: template: _default/single.html:73:12: executing "_default/single.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/12/05 23:31:42 render of "page" failed: "/Users/.../Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/_default/baseof.html:73:12": execute of template failed: template: projects/single.html:73:12: executing "projects/single.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/12/05 23:31:42 render of "page" failed: "/Users/.../Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/_default/baseof.html:73:12": execute of template failed: template: projects/single.html:73:12: executing "projects/single.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
ERROR 2022/12/05 23:31:42 render of "page" failed: "/Users/.../Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/_default/baseof.html:73:12": execute of template failed: template: publications/single.html:73:12: executing "publications/single.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
Error: Error building site: failed to render pages: render of "page" failed: "/Users/.../Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/_default/baseof.html:73:12": execute of template failed: template: projects/single.html:73:12: executing "projects/single.html" at <.Hugo.Generator>: can't evaluate field Hugo in type *hugolib.pageState
Total in 141 ms

If you have any ideas on how to fix this, then I am all ears!

Search for .Hugo. and replace with hugo..

Thank you @bep. After your suggestion I get the following errors:

ERROR 2022/12/06 22:47:34 render of "page" failed: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/projects/single.html:38:11": execute of template failed: template: projects/single.html:38:11: executing "content" at <partial "posts/series" .>: error calling partial: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/partials/posts/series.html:1:22": execute of template failed: template: partials/posts/series.html:1:22: executing "partials/posts/series.html" at <.URL>: can't evaluate field URL in type *hugolib.pageState
ERROR 2022/12/06 22:47:34 render of "page" failed: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/projects/single.html:38:11": execute of template failed: template: projects/single.html:38:11: executing "content" at <partial "posts/series" .>: error calling partial: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/partials/posts/series.html:1:22": execute of template failed: template: partials/posts/series.html:1:22: executing "partials/posts/series.html" at <.URL>: can't evaluate field URL in type *hugolib.pageState
ERROR 2022/12/06 22:47:34 render of "page" failed: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/projects/single.html:38:11": execute of template failed: template: projects/single.html:38:11: executing "content" at <partial "posts/series" .>: error calling partial: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/partials/posts/series.html:1:22": execute of template failed: template: partials/posts/series.html:1:22: executing "partials/posts/series.html" at <.URL>: can't evaluate field URL in type *hugolib.pageState
ERROR 2022/12/06 22:47:34 render of "page" failed: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/projects/single.html:38:11": execute of template failed: template: projects/single.html:38:11: executing "content" at <partial "posts/series" .>: error calling partial: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/partials/posts/series.html:1:22": execute of template failed: template: partials/posts/series.html:1:22: executing "partials/posts/series.html" at <.URL>: can't evaluate field URL in type *hugolib.pageState
Error: Error building site: failed to render pages: render of "page" failed: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/projects/single.html:38:11": execute of template failed: template: projects/single.html:38:11: executing "content" at <partial "posts/series" .>: error calling partial: "/Users/luisfraguada/Documents/dev/elizabethbiggerdotcom/themes/hugo-coder/layouts/partials/posts/series.html:1:22": execute of template failed: template: partials/posts/series.html:1:22: executing "partials/posts/series.html" at <.URL>: can't evaluate field URL in type *hugolib.pageState

The code at .../hugo-coder/layouts/projects/single.html:38:11 is : {{ partial "posts/series" . }}
The code at partials/posts/series.html:1:22 is:
{{ $currentPageUrl := .URL }}

Replace .URL with .RelPermalink.

Start building sites … 
hugo v0.107.0+extended darwin/amd64 BuildDate=unknown

                   | EN  
-------------------+-----
  Pages            | 22  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     | 47  
  Processed images |  0  
  Aliases          |  4  
  Sitemaps         |  1  
  Cleaned          |  0  

Total in 149 ms

Yes!

There were several other places where there was a .URL. Thanks @bep and @jmooring for the help!

1 Like

Be careful. A global replace may break other things, depending on your theme or layouts.

The .URL method is still valid for menu entries and pagination pagers.

1 Like

I went bit by bit replacing .URL in the theme until there were no errors. Testing thoroughly today and everything seems to be working correctly.

1 Like

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