This guide explains how to use the AMP Validator tool, often referenced in Google Search Console (GSC), to identify and fix errors on your Accelerated Mobile Pages (AMP). Correctly validated AMP pages are crucial for appearing in Google's mobile search results and delivering fast content to users.
Step 1: Identify AMP Errors in Google Search Console
The first thing we need to do is locate the AMP pages on your site that have errors:
- Log in to Google Search Console (GSC) and select your website property.
- From the left-hand menu, go to Experience > AMP. (The report may be called AMP Status.)
- Here, you’ll see the status of all your AMP pages: Error – pages with issues, Valid with warnings – pages that are mostly fine but need attention, Valid – pages that are good to go
- Click on Error to see the details. Errors are grouped by type, like “Custom JavaScript is not allowed” or “Mandatory tag missing.”
- Click on a specific error type to see which pages (URLs) are affected. Copy one of these URLs—you’ll use it in the next step to validate the page.
Step 2: Validate the AMP URL Using the Official Tool
While GSC identifies the error, the official AMP Validator provides the precise line number and details necessary for debugging.
- Open the Official AMP Validator Tool. This tool is available directly on the web at validator.ampproject.org.
- Paste the problematic AMP URL you copied from GSC into the input field.
- Click the Validate button.
Step 3: Analyze the Validator Output
The validator tool will return one of two statuses: PASS or FAIL. If it fails, the tool displays a detailed list of errors that need to be addressed.
- Review the Error Messages: The output provides the specific error, a description of why it failed, and most importantly, the line number where the issue is located in your AMP HTML source code.
- Understand Common Errors:
- Invalid HTML Tag: You may have used a standard HTML tag (like <img> or <video>) that must be replaced with its AMP-specific component (like <amp-img> or <amp-video>).
- Custom JavaScript: AMP pages cannot contain custom, third-party JavaScript; functions must be implemented using AMP components.
- Restricted CSS: CSS is limited to the <style amp-custom> block and cannot exceed 75KB. Issues often relate to using external stylesheets or using disallowed CSS rules.
Step 4: Resolve the Errors in Your Code
Use the information from the validator to make corrections to the source code of your page.
- Locate the Error: Using the line number provided by the validator, open the source code of the affected page (or the template responsible for generating that page).
- Apply the Fix: Make the necessary changes based on the error message. For example, if the error is "The tag 'img' is disallowed," replace the standard <img> tag with a correctly formatted <amp-img> tag, ensuring it includes width, height, and layout attributes.
- Re-validate Locally: Before deploying the change, run the modified code through the AMP Validator again (Step 2) to ensure the error is fully resolved.
Step 5: Validate and Request Indexing in GSC
Once you have fixed the errors in your code and deployed the changes, you must inform Google that the pages are now valid.
- Return to GSC: Go back to the AMP Status report in Google Search Console.
- Run the Live Test: Click the TEST LIVE URL button for one of the URLs you fixed. This runs a fresh validation.
- Click Validate Fix: If the live test passes, return to the error report and click the Validate Fix button associated with that error type. This tells Google to start re-crawling all affected pages to confirm the issue is resolved.
Once Google recrawls the pages, the error count in GSC will drop, and your valid AMP pages will be eligible for indexing.