问题原文
原帖链接 · Rad · CC BY-SA 4.0
I have the almost same question as this:
But I am confused with the accepted answer, as for my case, the website is hosted using GitHub Pages and has only one html in root directory: index.html
.
├── assets
├── index.html
├── manifest.json
├── robots.txt
├── sitemap.xml
So, What should be my sitemap.xml and canonical url in index.html ?
Should it be like this? sitemap.xml:
<url>
<loc>https://example.github.io/</loc>
<lastmod>2021-10-19</lastmod>
<priority>1.00</priority>
</url>
and in index.html
<link rel="canonical" href="/"/>
I am very new to this and would appreciate a specific answer to this.
For more info:
Currently my sitemap only contains https://example.github.io/ and no canonical url in index.html
Google Search Console url inspection for https://example.github.io/ says:
Coverage [Indexed, not submitted in sitemap]
Sitemaps: N/A
User-declared canonical: None
Google-selected canonical: Inspected URL
已采纳解答
原帖链接 · Trebor · CC BY-SA 4.0
The message you're receiving from Google "Indexed, not submitted in sitemap" is typical of any page Google finds through any means other than a sitemap. It's not an error.
If you only have one page, index.html and Google has already found it, you really don't need a sitemap. Sitemaps are not necessary in most cases and Google seems to prefer finding pages via links. A site can have many pages in a sitemap, and GGC will refer to the majority of them via the message you have received. It simply means the pages were found through other means first.
Additional information
Additionally, sitemaps are designed to point to URLs you want indexed (that maybe can't be found via other methods). These can include both the top of your domain, as in example.com, and pages such as example.com/index.html.
In regards to canonicals, a canonical is meant to point the user to another similar or identical page. It's designed to tell search engines the original source for content. However, putting a canonical link on your home page is also considered good practice. You can use something similar to <link rel="canonical" href="https://example.com/"> in your header. Or in your situation, <link rel="canonical" ref="https://example.github.io/">
See also Should homepage be set up as canonical?
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
