
- Google AMP 教程
- Google AMP - 首頁
- Google AMP - 概述
- Google AMP - 簡介
- Google AMP - 圖片
- Google AMP - 表單
- Google AMP - iframe
- Google AMP - 影片
- Google AMP - 按鈕
- Google AMP - Timeago
- Google AMP - Mathml
- Google AMP - Fit Text
- Google AMP - 倒計時
- Google AMP - 日期選擇器
- Google AMP - 故事
- Google AMP - 選擇器
- Google AMP - 連結
- Google AMP - 字型
- Google AMP - 列表
- Google AMP - 使用者通知
- Google AMP - 下一頁
- Google AMP - 屬性
- 樣式和自定義 CSS
- Google AMP - 動態 CSS 類
- Google AMP - 操作和事件
- Google AMP - 動畫
- Google AMP - 資料繫結
- Google AMP - 佈局
- Google AMP - 廣告
- Google AMP - 分析
- Google AMP - 社交小部件
- Google AMP - 媒體
- HTML 頁面到 AMP 頁面
- Google AMP - 基本語法
- Google AMP - 驗證
- Google AMP - 快取
- Google AMP - 自定義 JavaScript
- Google AMP - CORS
- Google AMP 有用資源
- Google AMP - 快速指南
- Google AMP - 有用資源
- Google AMP - 討論
Google AMP - 驗證
Google AMP 是一種使網頁在裝置上載入更快的途徑。要使用 AMP,我們可以利用 HTML5、CSS 和 AMP 元件。
Google AMP 提供了許多驗證 AMP 頁面的方法。我們將在此章中討論的一些重要方法包括:
使用 #development=1
使用 AMP 驗證器
使用命令列
讓我們詳細討論每個方法。
使用 #development =1
一旦您知道您的頁面已準備好進行驗證,只需將 #development=1 新增到頁面 URL 的末尾,並在 Chrome 開發者工具中進行測試。
您可以將 #development=1 新增到 HTML 頁面 URL 的末尾,如下例所示:
https://:8080/googleamp/test_amp.html#development=1
在瀏覽器和 Google Chrome 控制檯中訪問上述 URL。它將列出 AMP 認為從 AMP 規範角度來看無效的錯誤。
以下是我們針對 test_amp.html 獲取的錯誤。

您可以修復顯示的錯誤,一旦所有錯誤都修復後,它將顯示如下:

使用 AMP 驗證器
AMP 有一個驗證器工具,我們可以輸入 HTML 內容,它會顯示狀態為 PASS 或 ERROR,並顯示頁面上的錯誤。連結如下:https://validator.ampproject.org/
AMP 驗證器工具的顯示如下所示:

頁面內容中錯誤的示例如下所示:

使用命令列
您可以使用以下命令安裝 npm 包:
npm install -g amphtml-validator

我們建立了一個資料夾 amptest/ 並將 amp_test.html 檔案儲存在該資料夾中。讓我們在命令列中使用以下命令驗證 amp_test.html。
amphtml-validator youramppage.html

讓我們從頁面中刪除一些標籤,看看它是否顯示錯誤。

可以修復顯示的錯誤,直到我們獲得狀態為 PASS。
廣告