从零开始,手把手教你让 Google 和 Bing 找到你的博客文章
告诉搜索引擎"这个页面的正式地址是哪里"
在 GitHub 仓库找到 index.html,点铅笔图标编辑,按 Ctrl+F 搜索 canonical
<!-- 错误示例(指向别人的网站)--> <link rel="canonical" href="https://other-account.github.io/"> <!-- 正确示例(填你自己的博客地址)--> <link rel="canonical" href="https://你的用户名.github.io/博客仓库名/">
填写提交说明,比如"fix: 修正 canonical URL",然后保存。
确保 sitemap 里的文章链接指向你自己的网站
// 错误示例 const BASE_URL = 'https://other-account.github.io'; // 正确示例(改成你自己的地址) const BASE_URL = 'https://你的用户名.github.io/博客仓库名';
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://你的用户名.github.io/博客名/</loc>
<lastmod>2026-06-17</lastmod>
<priority>1.0</priority>
</url>
<url>
<loc>https://你的用户名.github.io/博客名/posts/文章名.html</loc>
<lastmod>2026-06-17</lastmod>
<priority>0.8</priority>
</url>
</urlset>
访问 https://你的博客地址/sitemap.xml,确认所有链接都是你自己的域名。
向 Google 证明你是网站所有者,并提交文章目录
访问 search.google.com/search-console,用 Google 账号登录
https://你的用户名.github.io/博客名/Google 会给你一个 googleXXXXXXXX.html 文件,下载后上传到 GitHub 仓库根目录(和 index.html 同级)。
先在浏览器打开 https://你的博客地址/googleXXXXXXXX.html,能看到内容后,回到 Search Console 点「验证」。
点「前往资源」进入控制台 → 左侧菜单点 Sitemap → 输入框填 sitemap.xml → 点提交。
顺手提交 Bing,覆盖更多搜索流量
访问 bing.com/webmasters,用微软账号登录
填入博客地址,按提示完成验证(可选择 XML 文件验证,步骤类似 Google)
进入控制台后找到「网站地图」,填入 https://你的博客地址/sitemap.xml 提交。
方便以后随时手动刷新 sitemap,不用等推文章
在 on: 下面加一行 workflow_dispatch:
on: workflow_dispatch: # 加这一行,允许手动触发 push: paths: - 'posts/**.html'
仓库页面 → Actions → 左侧选 workflow 名称 → 右上角点 Run workflow
ccna-exam-guide.html,这样 URL 更规范,搜索引擎处理起来更友好。中文文件名在技术上可以收录,但不是最佳实践。