為網頁中繼資料使用有效的 HTML 程式碼,可確保 Google 能依設定使用中繼資料。即使 HTML 無效或與 HTML 標準不一致,Google 仍會嘗試理解 HTML,但標記中的錯誤可能導致 Google 搜尋使用中繼資料的方式發生問題。用來指定網頁相關中繼資料的主要元素是 HTML 文件的 <head> 元素。如果在 <head> 元素中使用無效元素,Google 會忽略無效元素之後顯示的任何元素。
在 <head> 元素中使用有效元素
根據 HTML 標準,<head> 元素只能包含下列有效元素,且不可包含其他無效元素:
title
meta
link
script
style
base
noscript
template
請勿在 <head> 元素中使用無效元素
除了上述元素以外,<head> 元素中的 HTML 標準不允許任何其他元素。<head> 元素中顯示的以下常見元素為無效元素:
iframe
img
強烈建議您不要在 <head> 元素中使用這些無效元素,但如果一定要用,請將這些無效元素放在您希望 Google 看到的元素後方。Google 只要偵測到任一無效元素,就會認定那是 <head> 元素的結尾,並停止讀取 <head> 元素中的任何後續元素。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-08-04 (世界標準時間)。"],[[["\u003cp\u003eUtilize valid HTML for page metadata to ensure Google can properly interpret and use it in search results.\u003c/p\u003e\n"],["\u003cp\u003eInclude metadata within the \u003ccode\u003e<head>\u003c/code\u003e element of your HTML document, using only the valid elements specified by the HTML standard: \u003ccode\u003etitle\u003c/code\u003e, \u003ccode\u003emeta\u003c/code\u003e, \u003ccode\u003elink\u003c/code\u003e, \u003ccode\u003escript\u003c/code\u003e, \u003ccode\u003estyle\u003c/code\u003e, \u003ccode\u003ebase\u003c/code\u003e, \u003ccode\u003enoscript\u003c/code\u003e, and \u003ccode\u003etemplate\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAvoid using invalid elements like \u003ccode\u003e<iframe>\u003c/code\u003e and \u003ccode\u003e<img>\u003c/code\u003e within the \u003ccode\u003e<head>\u003c/code\u003e element as this can disrupt Google's parsing and cause metadata to be ignored.\u003c/p\u003e\n"],["\u003cp\u003eIf you must use invalid elements, place them after the valid metadata elements to minimize potential issues.\u003c/p\u003e\n"]]],["Valid HTML is crucial for Google to utilize page metadata correctly. The `\u003chead\u003e` element is key for this; only specific elements (`title`, `meta`, `link`, `script`, `style`, `base`, `noscript`, `template`) are allowed within it. Invalid elements, like `iframe` or `img`, cause Google to ignore any subsequent elements within `\u003chead\u003e`. Avoid invalid elements; if used, place them after valid ones to ensure Google reads the desired metadata first.\n"],null,[]]