HTML </head> seems to be stripped out during Netlify build


I’m running into a strange issue where the HTML </head> tag is being removed when my site is built with Netlify. This is not happening when building locally w/ Jekyll - although I am new to Netlify, so it’s possible that I’m doing something wrong.

Here’s some details:

The website is deployed to Netlify at, and uses Jekyll as well as the Hydejack theme.

When I load the page, I see that the </head> tag is missing, and the <body> starts after the last script I’ve included. When run bundle exec jekyll serve locally, I can see that the </head> is there. While debugging this, I’ve tried adding an extra </head> tag immediately after my last script - but the Netlify build strips that out as well.

I’m not seeing any errors in the deploy log, or any indication of what is happening. I’m wondering if there is a discrepancy between the two environments that is causing this to happen - but I’m not really sure how to troubleshoot this further. Can someone point me in the right direction to figure this out?


Hey @paulcalvano and welcome :wave:

I just checked out your site and was able to find the <head></head> tags- maybe you’ve resolved this since writing in?

Hi @jen. Thanks for looking into this!

It looks like you are looking at the rendered HTML via the Inspector. The browser appears to be adding the </head> when it builds the DOM because it is able to detect the error and workaround it. I can see that happening in Chrome, Safari and Firefox.

However if you look at the raw HTML that is served, either in the Network tab of Firefox/Chrome/Safari or the Sources tab in Chrome/Safari - you’ll see that the HTML is being served to the browser w/o the </head>.

Hey @paulcalvano,
You’re totally right, and I was able to confirm that missing tag. None of the things I checked on the Netlify side turned up anything that would explain what’s happening- you’re not injecting snippets, using post processing, no build errors (as you already explained!), and I didn’t see any issues about this in the Jekyll repo. I did come across this one vaguely related issue:

It’s several years old, but suggests that in the past there have been silent errors in Jekyll plugins that affect the HTML tags. The only other similar report we’ve seen here was also related to the static site generator:

Some experiments you could try would be:

  • generating the build locally and then deploying to Netlify manually via drag and drop
  • deploying your site on another host and seeing if you get the same issue

I wish I had something more conclusive for you!

Thanks Jen. I appreciate all the details.

Few things I’ve tried since:

  • I tried deploying the theme without any changes to a new Netlify build, and I’m seeing the same behavior.
  • I also tried deploying a static HTML file to see if that was being modified. The HTML was served unmodfied.

This seems to correlate with the other issues you shared. ie, something must be failing silently in the build and stripping out the </head>. I’ll update this thread if I’m able to figure it out…


Please do, we always appreciate (and benefit) when people are willing to share back their learnings here :memo: