Can HTML contain two HEAD tags
The short answer is YES.
It's not a good solution but it will absolutely work.
People usually answer these questions in theory, like "no, because it's not valid by the standards". That's right, it's not. Future browsers might not support it, some source parsers may get confused, HR/IT experts checking out your portfolio may think you know less than Jon Snow, and all sorts of bad things. In theory. But it does happen out there in the real world, and browsers are not stupid: they know what you mean, they will take both head tags and work as expected.
And it's not just by chance.
They have very good reasons:
1. Head tag is optional. (see notes below the article!)
Browsers accept headtag-like contents even outside it, so in effect they ignore the tag itself completely. And if they ignore one, they will probably ignore several, too.
2. Visitors are precious.
Browsers want you to enjoy your time. They want to show you the best possible page they can compose out of the mess they've got. It's their intention, they want to show you that the internet works, not teach you how bad your favorite website is. If they can find out what the html code wants to express (and there's no deadly ambiguity in the structure), they will do their best to fix the page.
3. Bad markup tolerance is a thing.
Browsers are not just patient and forgiving, but sometimes they do acrobatic moves to get your stuff working. Look at this horrible mess:
<!-- no doctype! -->
<!-- no HTML tag! we're all gonna die! -->
<head>
<style>
body {background:#002233;}
</style>
</head>
<head><!-- let's twist again! -->
<style>
body {color:white}
</style>
<!-- we didn't even close the second one!! -->
See this text?<br>
With the background AND color properly set?<br>
<br>
Your browser's quite a badass.
About browser tolerance, here's a lot more with super-ugly examples - make sure you forget everything you've seen when you're back!)
So yes, of course, the principle is "be a good friend of your browser", no matter how cleverly it fixes your mistakes. But if you wake up in a dark dungeon with hungry lions around and your only way out is using two <head> tags - well, don't hesitate! It's not broken syntax, it's not a serious violation of HTML5 rules - it's no more than a convenient cheat. And don't fall for the widespread myth that non-standard, non-tidy sites prosper a lot worse: people usually just don't know for sure and want to stay on the safe side. Typically they are the ones who describe hell as a place where validator-failing web authors go.
TLDR: In practice, two head tags work.
Now please have only one if possible.
ADDITIONAL NOTES
As @StanislavBerkov pointed out, both W3C and MDN suggests that the HEAD tag is implied, meaning it's probably better to just leave the head
tag entirely. I would not recommend this approach if you have the standard option of using only one of it, but having none is apparently better than having two. The documentation is not very clear around the topic so make sure you test everything in the major browsers - but again, in practice, you'll face no issues.
It's not valid according to the standard
Relevant part:
4.2.1 The head element
Categories: None.
Contexts in which this element can be used: As the first element in an html element.
Your second <head>
element wouldn't be the first element in the html document.