Hugo theme stopped working with hugo 0.50: how to fix it?

Greetings,

I have been building my blog with Hugo without problems, for 2+ years now, on an Ubuntu 16.04LTS box. The last post was built and published without problems on Oct 10th 2018, using hugo 0.49. After that day, the only hugo-related thing I did was upgrade to hugo 0.50. Right now “hugo version” returns:

version v0.50 linux/amd64 BuildDate: 2018-10-29T12:39:37Z

It appears that the theme I have been using is not compatible with this version of hugo. I get lots of errors like this:

"/home/marco/hugo/themes/aglaus-noamp/layouts/_default/baseof.html:16:84": execute of template failed: template: _default/single.html:16:84: executing "_default/single.html" at <.Source.Path>: can't evaluate field Source in type *hugolib.Page

The relevant part of baseof.html, and the complete code of single.html are below. I assume I should change something in baseof.html, but what, exactly, and above all: why?

Thanks!

cat -n baseof.html | head -20

 1	<!DOCTYPE html>
 2	<html>
 3	  <head>
 4	    {{ partial "meta.html" . }}
 5	    {{ with .Site.Params.googlefonts }}
 6	    <link href="{{ . }}" rel="stylesheet">
 7	    {{ else }}
 8	    <link href="https://fonts.googleapis.com/css?family=Lobster|Lato:400,700" rel="stylesheet">
 9	    {{ end }}
10	    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
11	    <title>{{ block "title" . }}{{ end }}{{ .Site.Title }}</title>
12	    {{ block "meta" . }}{{ end }}
13	    <style>
14	      {{ replaceRE " +" " " (replaceRE "\n" "" (partial "styles.css" .)) | safeCSS }}
15	
16	      {{ range where .Site.Pages ".Params.thumbnail" "!=" nil }} .article-{{ .Source.Path | md5 }} .thumbnail { background-image: url({{ $.Site.BaseURL }}{{ .Params.thumbnail }});  } {{ end }}
17	    </style>
18	  </head>

cat -n single.html

 1	{{ define "title" }}{{ .Title }} - {{ end }}
 2	
 3	{{ define "meta" }}
 4	{{ partial "single_meta.html" . }}
 5	{{ partial "single_json_ld.html" . }}
 6	{{ end }}
 7	
 8	{{ define "main" }}
 9	{{ .Render "summary" }}
10	{{ end }}

It seems that Source was removed while cleaning hugo.

You can use .File should do the trick.

See more informations about that here : https://github.com/vjeantet/hugo-theme-docdock/issues/166

2 Likes

Yep, it’s even in the Release log for v0.50:

Remove the now superflous Source struct 7930d213 @bep #5324

2 Likes

indeed, replacing all occurrences of .Source with .File seems to have solved the problem. Thanks