Hugo put unknown character right after body tag


I’m using latest version of hugo, I have head.html file, contains some meta, css files & other usual head content. when I try to include the partial on some html file (let’s say index.html) using {{ partial "head.html" . }}, the content injected to the page successfully, but there is an issue.

Hugo add some unknown character right after <body>, when I view Page source in browser, the head & body tag shows as red, that means there some problem, also I have margin on top on my page (because of that character), notice that I using some other partials in my page (in body tag) and they are fine, also if I don’t use partial for head section (repeat head tag in my page(s), everything works fine)

Screenshot of the problem

Can you please help me on this?

Does this dot display visually on the page or is this a red indicator from your browser’s dev tools letting you know the actively selected element?

Its visible only in dev tools

And if it’s not in the output site, I wouldn’t worry about it:)

I didn’t worry if it was only visible on console, but as I said because of that character, I have margin in top of all my pages (like I added body: margin-top: 20px in my stylesheet), also if I try to view source of the page, the head and body tag shown as red, this means there is something wrong with HTML.

Also in dev tools, all meta & css link shown in body instead of head tag. I tired to use hugo instead of hugo server to see if this issue is exists only in memory, but it happened in final output too.

I doubt that HUGO adds that character – you should check your templates.

I mentioned in my first post here, without using partial in head, everything is fine.

A partial is also a template. If you cannot show the full source, this is impossible for us to debug.

I just created new site (using hugo new site) and copy/paste all content from old one to new and the character gone! I don’t know why but everything is fine now.

Thanks for your time & support.

1 Like