請將以下步驟作為工作檢查清單,並依據專案的證據、範圍與限制調整。
實用步驟
- 開啟要檢查的頁面和瀏覽器開發人員主控台。行動版溢位檢查器請先使用回應式模式。
- 檢查程式碼,將完整片段貼到主控台並按 Enter。它會讀取目前頁面;只有 sitemap 中繼資料工具和同源檢查器會發出有限的請求。
- 檢視主控台輸出或下載的 CSV/JSON。瀏覽器政策、驗證狀態和不支援的伺服器方法可能導致部分檢查無法得出結論。
(() => {
const meta = (name, attr = 'name') => document.querySelector('meta[' + attr + '="' + name + '"]')?.content || '';
const links = (rel) => [...document.querySelectorAll('link[rel="' + rel + '"]')].map((node) => ({ href: node.href, hreflang: node.hreflang || '' }));
const report = {
url: location.href,
title: document.title,
titleLength: document.title.length,
description: meta('description'),
descriptionLength: meta('description').length,
robots: meta('robots'),
canonical: links('canonical')[0]?.href || '',
language: document.documentElement.lang || '',
headings: Object.fromEntries([1, 2, 3, 4, 5, 6].map((level) => ['h' + level, [...document.querySelectorAll('h' + level)].map((node) => node.innerText.trim()).filter(Boolean)])),
hreflang: links('alternate').filter((item) => item.hreflang),
openGraph: Object.fromEntries([...document.querySelectorAll('meta[property^="og:"]')].map((node) => [node.getAttribute('property'), node.content])),
twitter: Object.fromEntries([...document.querySelectorAll('meta[name^="twitter:"]')].map((node) => [node.name, node.content])),
jsonLdBlocks: document.querySelectorAll('script[type="application/ld+json"]').length,
};
console.table({ title: report.title, titleLength: report.titleLength, descriptionLength: report.descriptionLength, robots: report.robots, canonical: report.canonical, language: report.language, h1Count: report.headings.h1.length, hreflangCount: report.hreflang.length, jsonLdBlocks: report.jsonLdBlocks });
console.log('Full SEO page report:', report);
const link = document.createElement('a');
link.href = URL.createObjectURL(new Blob([JSON.stringify(report, null, 2)], { type: 'application/json' }));
link.download = 'seo-page-audit.json';
link.click();
setTimeout(() => URL.revokeObjectURL(link.href), 1000);
})();執行前請先審查。此指令碼會讀取目前頁面;只有 sitemap 和連結稽核會發出有限的同源請求。請求不會帶上 cookies;指令碼不會變更網站內容。