We can use the html2pug npm package to convert HTML to Pug in JavaScript / Node.js. The fragment option tells html2pug whether to wrap your HTML in an tag, if it isn't already.fragment is false by default, which means html2pug will always prepend html\n head\n body\n to the output by default.

Read more of this post