Adding a check for a custom head section just before closing the head tag.