[error] layouts/partials/footer.html: SyntaxError: Unexpected closing tag "body". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (3:1)
[error] > 3 | </body>
[error] | ^^^^^^^
Like many, I have opened the body tag in a
header.html file and am closing it in the
footer.html file. I have a general rule to surrender to defaults until I have a good reason to override them. After a year of using prettier, I finally do have a reason now that I am rebuilding a site with Hugo.
I am guessing there is a
.prettierrc setting to suppress this check but I haven’t found it yet. I see there are others using prettier with Hugo. I hope one of you can clue in the newbie.
Not sure how many “many” is…
With Hugo templates I always open and close the body element within baseof.html.
Thank you. I will learn a bit and, I expect, follow your lead. The many, I guess, are just the few I have selected as examples to study. I may need to broaden my sample size.
For the record. At the moment the Hugo Docs has an example of a
header.html that ends with an open body tag.
See: Partial Templates | Hugo
Opening or closing the
<body> outside of baseofhtml seems like a poor way to organise a layout. My expectation, and preference, would always be that a component “does what it says on the tin” and that, for example,
layout/partials/site-footer.html contained only the site footer.
In my experience, clean and clear beats clever, every time.
It’s also worth noting that neither
<footer> are required elements, unlike
<body>, so it is unsafe to always assume that they will always be included.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.