跳至主要内容

將部署的網頁登錄到 Google Search Console 與 Analytics

Google Search Console

新增網站資源

  1. 點擊 +新增資源
  2. 下載驗證用 HTML 檔案,放到專案的 static/ 資料夾。
  3. 部署到 GitHub:
git push origin main
  1. 等待約 1 分鐘後,回到 Search Console 點擊 驗證
  2. 驗證成功後,網站資源就新增完成。

提交 Sitemap

  1. docusaurus.config.js 更新網站基本資料:
docusaurus.config.js
import {themes as prismThemes} from 'prism-react-renderer';

/** @type {import('@docusaurus/types').Config} */
const config = {
title: '_____', // 網站名稱
tagline: '_____', // 網站簡介
favicon: '_____', // 建議放在 img/favicon.svg

stylesheets: [
{ href: 'https://unpkg.com/@mantine/core@7/styles.css', type: 'text/css' },
],

presets: [
[
'classic',
{
docs: {},
blog: {},
theme: { customCss: './src/css/custom.css' },
gtag: {
trackingID: '_____', // 如果要加入 Analytics
anonymizeIP: true,
},
},
],
],

plugins: [
['@docusaurus/plugin-content-docs', {}],
[require.resolve("@easyops-cn/docusaurus-search-local"), {}],
],

themeConfig: {
image: '_____', // 社群分享圖
metadata: [
{ name: 'keywords', content: '_____, _____' },
{ name: 'description', content: '_____' },
{ name: 'og:title', content: '_____' },
{ name: 'og:description', content: '_____' },
{ name: 'twitter:card', content: 'summary_large_image' },
],
},
};

export default config;
  1. 部署更新到 GitHub:
git push origin main
  1. 等待約 1 分鐘後,回到 Search Console → 左側選單點 Sitemap
  2. 輸入 sitemap.xml 並提交,狀態顯示 成功 即可。

Google Analytics

  1. 前往 Google Analytics
  2. 點擊「管理」 → 建立資源,填入網站資訊。
  3. 選擇平台 網站,填入網址與串流名稱 → 建立。
  4. 生成 評估 ID
  5. 安裝 Docusaurus gtag 插件:
npm install --save @docusaurus/plugin-google-gtag
  1. 修改 docusaurus.config.js,在 presets 中加入 gtag 設定:
docusaurus.config.js
gtag: {
trackingID: '_____', // Google Analytics 評估 ID
anonymizeIP: true,
}
  1. 部署到 GitHub:
git push origin main
  1. 回到 Google Analytics →「即時」報表確認資料是否傳送。

建置 robots.txt

robots.txt 是給搜尋引擎爬蟲的指南,告訴它哪些頁面可以抓取,哪些不要抓。

  1. 在專案的 static/ 資料夾新增 robots.txt
  2. 範例內容:
robots.txt
User-agent: *
Allow: /
Disallow: /search/
Disallow: /tags/

Sitemap: https://你的網址/sitemap.xml
  • User-agent: *:適用於所有爬蟲(Google、Bing 等)
  • Allow: /:允許抓取全站內容
  • Disallow:阻止爬蟲抓取不必要的頁面
  • Sitemap:明確告訴爬蟲地圖位置,加速索引

PageSpeed Insights

  1. 前往 PageSpeed Insights 填入網站網址。
  2. 查看改善建議,將紅色部分貼給 AI 或工程師分析優化方法。

Open Graph 標籤測試

  1. 前往 Facebook Sharing Debugger,輸入網址。
  2. 按下「偵錯」抓取網站資訊,確認 Open Graph 標籤正確顯示。

Bing Webmaster Tools

  1. 前往 Bing Webmaster Tools
  2. 左上角 → 新增網站 → 從 Google Search Console 匯入網站。