-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: incorrect canonical
and alternative
URL annotations
#2159
Conversation
Theme name validation passed. |
221d576
to
5320be2
Compare
3c0a88f
to
7c9847e
Compare
Thanks! Fixed in 7c9847e. For pages where permalink is not set, the same URL as |
Thanks for the review and merge! I believe that by improving search results, more people will use this amazing tool! |
Check List
Summary
There is a problem with the
canonical
andalternative
URL annotations in the<head>
tag of the page where the translation exists.This is probably why when we search for "hexo" on Google, we get strange results in some languages.
This pull request provides corrections to errors and improvements in
<head>
, with the aim of displaying search results as naturally as possible.Current
<head>
tagFor example, https://hexo.io/zh-tw/api/ outputs the following (excerpt):
For this example:
canonical
tag does not properly indicate a canonical URL because thepretty_urls.trailing_index: false
setting means the URL should end with '/'.alternative
is incorrect. The correct term isalternate
.alternate
tag incorrectly points to URLs with duplicate:lang
slugs, leading to either nonexistent URLs or URLs that incorrectly display content in English despite indicating a different language.alternative
again points to the URL for the language being displayed (zh-tw
in this example).There is a problem as above. In the screenshot at the beginning, it seems that Google is unable to recognize the correspondence between pages in each language, and this is probably the cause.
Fixes and improvements with this pull request
canonical
tag mentioned above. Omitindex.html
at the end.alternative
toalternate
above.alternate
above.alternate
does not output the displayed URL itself.alternative
is output in/:lang/about/
but the page does not exist. Delete this.As a result of these modifications, the URL annotation will look like this (excerpt):
Reference