大网数据广告活动
网站运营与故障问答

sitemap and canonical url for website that has only one page: "index.html" hosted using GitHub Pages

· 52CE 我爱测

I have the almost same question as this: How do I correctly add index page to xml sitemap - do I need a canonical expression? But I am confused with the accepted answer, as for my case, the website is hosted using GitHub Pages an…

问题原文

原帖链接 · 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.

See The Sitemap Paradox

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?

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-10-19)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。