Hi, I am trying to modify the template of a theme (Hugo Zen Theme GitHub - frjo/hugo-theme-zen: A fast and clean Hugo base theme with css-grid and Hugo pipes support.) and getting errors like the following:
ERROR 2023/05/22 11:15:16 "/Users/me/mysite/layouts/_default/baseof.html:19:1": parse failed: template: _default/single.html:19: unterminated quoted string
Error: Error building site: "/Users/me/mysite/layouts/_default/baseof.html:19:1": parse failed: template: _default/single.html:19: unterminated quoted string
My changed codes are like the following on base.html
Any suggestion to fix the error.
Sure. The message indicates there’s a problem on line 19 of layouts/_default/single.html.
Please copy/paste layouts/_default/single.html. Screen captures aren’t terribly helpful.
Here is the single.html file:
{{ define "main" -}}
<main class="main layout__main">
<article class="single-view{{ with .Section }} single-view--{{ . | urlize }}{{ end }}">
<header>
<h1 class="title {{ if $.Param "submitted" | default false }}mb--xxs{{ end }}">{{ .Title }}</h1>
{{ if $.Param "submitted" | default false }}{{ partial "submitted.html" . }}{{ end -}}
{{ if .Params.tags }}{{ partial "tags.html" . }}{{ end -}}
</header>
<div class="content">
{{ .Content }}
</div>
<div class="content content--bottom">
{{ if $.Param "relatedposts" | default false }}{{ partial "related.html" . }}{{ end -}}
{{ if ne .Lastmod .Date }}{{ partial "dates.html" . }}{{ end -}}
</div>
</article>
</main>
{{ end }}
Below is the screenshot (just to understand the line numbers)
You just posted the theme’s version of this file, not your version of the file.
Actually, I did not do any modification. So far, I created a partial which code looks below:
adsense.html
<div>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXXXXX"
crossorigin="anonymous"></script>
</div>
and later i add the line to add partial into baseof.html
I’m going to need access to the project repository, in a state where the failure is reproducible.
You have an extraneous newline in layouts/_default/baseof.html, line 20:
Replace this (two lines)
<body class="{{ if .IsPage }}single-page{{ else }}list-page{{ end }}{{ if .IsHome }} front{{ end }}{{ with $.Param "
bodyclass" }} {{ . }}{{ end }}">
With this (one line):
<body class="{{ if .IsPage }}single-page{{ else }}list-page{{ end }}{{ if .IsHome }} front{{ end }}{{ with $.Param "bodyclass" }} {{ . }}{{ end }}">
i removed that but still getting the same error. And the interesting thing is: I am using VSCode and when I am saving this it is coming to new line by autoformat.
Moreover, the other thing is, if we somehow open the main baseof.thml file from the original zen theme folder, it is generating error if i even save the file by simply save without any modification.
So, i believe, there is some other error is there which is causing the issue.
Works for me. Maybe you have fouled up your local copy of the theme.
Disable your auto formatting in vscode, you most likely have a plugin that is breaking your hugo code.