Encounting an error on hugo server command : "parse failed comment ends before closing delimiter"

Hi everyone!
I’m trying to work on an existing project and this is the first time I’m working with Hugo. So I followed the doc to install everything I need for that :

$ hugo env
hugo v0.111.3-5d4eb5154e1fed125ca8e9b5a0315c4180dab192+extended windows/amd64 BuildDate=2023-03-12T11:40:50Z VendorInfo=gohugoio
$ git version
git version 2.39.2.windows.1

After that, I tried to launch the project in VSCode and type the command hugo server but I get the following error which concern this file:

 process: loading templates: "C:\Users\roy\Desktop\projets\Green_IT\EcoIndex\layouts\partials\svg\inline-svg-use.html:1:1": parse failed comment ends before closing delimiter 
{{/* Add use svg reference from a symbol already in html
	* Example:
	* 	partial "inline-svg-use" "my-svg-id"

things to know:

  • I’m working with someone who updates the version of Hugo, go, and git. And it works perfectly fine for him
  • I tried to change the comment:
	* 	Need to import svg as symbol in html before (inline-svg.html)
-}}<svg aria-hidden="true"><use xlink:href="#{{ . | safeHTML }}" /></svg>

become this:

	* 	Need to import svg as symbol in html before (inline-svg.html)
*/}}<svg aria-hidden="true"><use xlink:href="#{{ . | safeHTML }}" /></svg>

By changing the comment I can launch the server. But If it’s the solution to solve the problem, why is it not working with the previous version of the comment that working for other people?

Try to clone the repo into a clean environment, and double-check that the you are running the appropriate hugo binary. Just cloned the repo and followed the install steps, the site built without errors (tested with hugo versions 0.102.3 and 0.111.3)

Hi and thank you for your response!
Sorry for the late reply but I tried to find some responses by myself (what is a clean environment and how to apply it)
So, I don’t know if it was a good way to create a clean environment because I have never done that but I used Docker (I have never used it before today).
But I still have the same error!
I used the extension Dev container in VSCode to create my container. And I use this one: vscode-dev-containers/containers/hugo at main · microsoft/vscode-dev-containers · GitHub
Add these features: go, git, and npm.

I suspect that “other people” are using macOS or Linux, where EOL is LF. You are using Windows, where EOL is CRLF. The other possibility is that you and “other people” have configured Git to behave differently (EOL conversion) when checking out a repository.

I can reproduce the error on Windows, but not on Linux.

Regardless, the comment delimiter should be on one line, either */}} or */ -}}.

I am surprised that your syntax works on macOS and Linux, because the Go examples indicate that the delimiters cannot be split between lines.

Thank you for your response and these explanations!
And effectively by changing the EOL directly on VSCode, I don’t have the error!

For the comment on several lines, I think is maybe thanks to this package?

A comment spanning several lines is fine, provided that the comment delimiter is not split between lines.

Whether the malformed delimiter was introduced by a particular editor or add-on, I have no idea, and is outside the scope of this forum.

oh okay, well I think I have a lot of things to learn yet!
Thank you again for the help!

1 Like

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