Remove variable quotation marks?

Hi all,
Playing around with Hugo and don’t understand the following with my code sample.

$varTest := "foo"

{{ $varTest }}

I outputs foo but like “foo” but wanted it to be foo without the quotation marks, when I remove them from $varTest Hugo gives me an error saying the variable is not valid.

However when I add {{ $varTest }} in a paragraph tag it removes the quotation marks?! I also tried adding | plainify but didn’t do anything.

Thanks in advance!

Please share the entire template.

That’s more or less it, just have a few files as of now.

baseof.html

{{ block "main" . }}

index.html

{{ define "main" }}
$varTest := "foo"

{{ $varTest }}
{{ end }}

Your example doesn’t make sense. Both lines need to be within double braces.

{{ $varTest := "foo" }}
{{ $varTest }}

Sorry my bad… I am on my phone so missed the double braces.

index.html

{{ define "main" }}

{{ $varTest := "foo" }}
{{ $varTest }}

{{ end }}

And that renders:

foo

No quotation marks.

1 Like