Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap meta information in <HEAD> tags #194

Merged
merged 2 commits into from
Jun 27, 2024
Merged

Wrap meta information in <HEAD> tags #194

merged 2 commits into from
Jun 27, 2024

Conversation

welcome-me
Copy link
Contributor

@welcome-me welcome-me commented Jun 22, 2024

I have a site that uses this theme, and I wanted to verify my ownership of it so I could use Google's search console. Google supplied a custom meta tag so I put it into layouts/partials/custom_head.html; however, I still failed Google's validation. Then, I realized that the output of layouts/partials/head.html is not wrapped in tags.

Once I added wrapped the output of head.html in <head> and </head>, I was able to verify my site.

@welcome-me welcome-me changed the title Add head tag to pages Wrap meta information in <HEAD> tags Jun 22, 2024
@zjedi
Copy link
Owner

zjedi commented Jun 24, 2024

I wonder, can you put the head tag inside the customization file? This looks like breaking change for everyone who already does that.

@welcome-me
Copy link
Contributor Author

welcome-me commented Jun 25, 2024

@zjedi Okay, so are you asking me to put it in layouts/partials/head.html? I'm fine with doing that if you think it is best. I don't know how other people do it.

@zjedi
Copy link
Owner

zjedi commented Jun 25, 2024

@welcome-me I don't know for sure how other people use it either :) I'm just trying to think critically about what could break.
Since nobody complained about this in the recent years, I assume it wasn't a problem or people were able to get around it.

From theoretical point of view, it's better to have the tag being customized in the customization file, since you may want to customize also that tag's attributes. That won't apply to head, because it has no attributes, but in general it sounds like more flexible way.

Just by checking the demo page's source, there IS proper head tag.
image

Your PR looks logical, but how come the demo does have the head? Won't adding the head duplicate the tag?

@zjedi
Copy link
Owner

zjedi commented Jun 26, 2024

Bear with me, I'll check this out at the weekend.

@welcome-me
Copy link
Contributor Author

welcome-me commented Jun 26, 2024

I'm a little confused. I'm not seeing a <head> tag after the <html> tag in the source for the example site. 🤔

Screenshot_20240626-163418_Via.png

@zjedi
Copy link
Owner

zjedi commented Jun 26, 2024

@welcome-me That is truly confusing because I do see head tag there. I can't see an explanation for getting different results here. I'm checking https://zjedi.github.io/hugo-scroll/ via desktop Chrome

@welcome-me
Copy link
Contributor Author

@welcome-me That is truly confusing because I do see head tag there. I can't see an explanation for getting different results here. I'm checking https://zjedi.github.io/hugo-scroll/ via desktop Chrome

I expect that the browser console is showing that there because those tags are supposed to be in the head tag. If you right click the page and click view the source, I think it will show that the head tag is not in the output we're generating for the browser.

@zjedi
Copy link
Owner

zjedi commented Jun 26, 2024

Aha, I am using inspect element. So the browser gives two different results based on inspection method. I still don't get it :) Do browsers just figure out there should be wrapping head tag when inspect element is used?

@welcome-me
Copy link
Contributor Author

Based on the below Stack Overflow answer and your experience with your browser inspector, it looks like the page is correctly parsed without the head tags. In fact, it looks like that's part of the HTML5 spec!

However, it is also true that implicit HEAD tags are required for verifying site ownership with Google. I don't know why we wouldn't want a three line change that increases compatibility with website analysis tools.

Does that make sense?

Is it necessary to write HEAD, BODY and HTML tags? - Stack Overflow
https://stackoverflow.com/questions/5641997/is-it-necessary-to-write-head-body-and-html-tags

@zjedi zjedi merged commit 807c028 into zjedi:master Jun 27, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants