AMP Validator - Test AMP pages

Validate AMP for Google Search

When it comes to Accelerated Mobile Pages there is no middle situation – the pages you have created are either AMP or not. So how do we know?

The important advantage of AMP isn't simply that it makes your web pages quick, but that it produces your webpages fast somehow so that can be approved. This way, third parties just like Twitter, Instagram or Google Search can feel great about providing AMP web pages to visitors in significantly exciting approaches.

A good news is the AMP project comes along with a handful of easy and convenient ways validating your pages and eventually – fixing up what's holding them from being approved as Accelerated ones. Once getting to know them you can freely pick up the one suiting you best and go including it in your AMP building workflow.

What follows is a fast glimpse over all of them:

Browser Developer Control console

Along with the AMP boilerplate, you have out of the box ready to go validator displaying you all needing your attention right into the browser's console. Firing it up is quite easy and straightforward – in order to inspect if a page is matching to the Accelerated Mobile Pages standard just add #development=1 to its URL being typed in your browser's address. This works universally so the page can actually resign and be previewed locally from your hard drive as well.

The goal is instead of http://~Some Path Over Here/is-it-AMP-page.html as a page's address to get something like ~ same as above here ~/ is-it-AMP-page.html#development=1 and, of course, hit Enter to reload the page. This will produce no visible change of pages appearance as it gets reloaded in your browser but if you open the Console section in your Developer Tools along with the other info there you'll also notice an eventual list of mistakes regarding the page's AMP validation starting with something like AMP validation had errors: on the first row and all of the errors listed down along with some simple error descriptions and eventually – some links giving you a hint about fixing the issue pointed out.

Once more, the exact same info, but serving as an step by step tutorial:

- Launch your AMP page in your web browser.

- Add "#development= 1" to the URL, for example, http://localhost:8000/released.amp.html#development=1.

- Start the Chrome DevTools console and check for verification faults.

Console problems are going to present like this:

This is probably the simplest way checking out if the pages you build to comply with AMP standard are actually fitting inside it – it requires no extra tools or steps outside the inventory you surely already have – your browser and developer tools. It is however just a bit too complicated since in order to get an overview over a pointed out mistakes you need to do some clicking forth and back and just might potentially get lost along the way or miss out a thing causing the very next validation attempt to fail again.

AMP Validator Web-based Interface

So as an alternative way you can also utilize the online validation tool the AMP guys had set up – it works with both plain codes pasted in the provided window or a live web page URL. Of course for development purpose, a clever approach would be uploading your page not from its permanent location but on some kind of a hidden subfolder of which knows only you, eventually, your team and the validator.

The web validation service provides you a live check if your pages are comply to the AMP or AMP4ADS standards. What it kind of seems to be better with is presenting you the list of mistakes inline in your code with some useful descriptions and Learn more.. links so you don't have to click in an attempt to fix it and to get them again along.

AMP Validator Web browser Extension for Chrome, Firefox and Opera

There also is a sometimes useful browser extension you can add – so far available for Chrome and Opera which only uses a simple icon indicator showing you up if the page you're currently viewing is or isn't an AMP one, is there any errors in it of, if an AMP alternative page with elements like AMP Header and AMP Menu is available.

The AMP Validator can be accessed directly from your internet browser's toolbar applying a browser extension. As you look, it is going to quickly confirm each AMP web page checked out and supplies a visual signifier of the validness of the webpage as a painted icon.

Yet another issue to mention touching NPM Packages NPM Packages for CI.

As part of your construct and test pipelines, you can utilize AMP affirmation by means of the AMP Validator NPM packs: amphtml-validator or gulp-amphtml-validator (a gulp plugin). For example, you can easily operate the AMP Validator NPM software for assimilation checks or in a schedule task to verify production AMP web pages.

Good example: Approving an AMP HTML file:

Within this case, we confirm an AMP HTML file utilizing the amphtml-validator NPM package. The supporting status is supplied out to the console.

'use strict';
var amphtmlValidator = require('amphtml-validator');
var fs = require('fs');

amphtmlValidator.getInstance().then(function (validator) 
  var input = fs.readFileSync('index.html', 'utf8');
  var result = validator.validateString(input);
  ((result.status === 'PASS') ? console.log : console.error)(result.status);
  for (var ii = 0; ii < result.errors.length; ii++) 
    var error = result.errors[ii];
    var msg = 'line ' + error.line + ', col ' + error.col + ': ' + error.message;
    if (error.specUrl !== null) 
      msg += ' (see ' + error.specUrl + ')';
    
    ((error.severity === 'ERROR') ? console.error : console.warn)(msg);
  
);
</code>

 Good example:  Utilizing a gulp  activity to  confirm <a href="http://ampexamples.com/amp-html-1410.html" class="linker">AMP HTML</a>:
 Within this  good example, we  come with a gulp task  which  approves  every one of <a href="http://ampexamples.com/amp-html-1410.html" class="linker">AMP HTML</a> files. If there's an AMP  affirmation error, the task exits  together with an error code (1).

<code>
const gulp = require('gulp');
const gulpAmpValidator = require('gulp-amphtml-validator');

const paths = 
  src: 'src/*.html'
;

gulp.task('amphtml:validate', () => 
  return gulp.src(paths.src)
    .pipe(gulpAmpValidator.validate())
    .pipe(gulpAmpValidator.format())
    .pipe(gulpAmpValidator.failAfterError());
);

gulp.task('default', ['amphtml:validate'], function () 
);

Command Line Method

You can confirm AMP HTML documents by utilizing the AMP HTML validator command line tool.

Starting:

1 - Make sure you have Node.js using its package administrator 'npm' on your system.

2 - Place the AMP HTML validator command line device by handling the following command: npm install -g amphtml-validator.

Now allow us to authorize a real AMP HTML webpage:

$ amphtml-validator https://www.ampproject.org/
https://www.ampproject.org/: PASS

Unsurprisingly this specific web page is legal AMP HTML. Let us aim a web page which is just not proven: several_errors. html. To run the amphtml-validator command, you can possibly deliver the WEBSITE ADDRESS of the webpage or a local document name. Load and save several_errors. html in to a document, after that run:

$ amphtml-validator several_errors.html
several_errors.html:23:2 The attribute 'charset' may not appear in tag 'meta name= and content='.
several_errors.html:26:2 The tag 'script' is disallowed except in specific forms.
several_errors.html:32:2 The mandatory attribute 'height' is missing in tag 'amp-img'. (see https://www.ampproject.org/docs/reference/amp-img.html)
several_errors.html:34:2 The attribute 'width' in tag 'amp-ad' is set to the invalid value '100%'. (see https://www.ampproject.org/docs/reference/amp-ad.html)
...

The type of the glitch notifications features file name, line, column, and text message, normally followed by a hyperlink to the AMP HTML reference. Some editors, incorporating Emacs ( seek compile command and compilation mode), can certainly analyze this structure and help you spring to the problems in the initial file.

To get a effective beginning part to create your very own AMP webpage look at minimum_valid_amp. html:

$ amphtml-validator minimum_valid_amp.html
minimum_valid_amp.html: PASS

The command line technique offers supplemental functions involving switching off the coloration, publishing JSON output or performing a certain version of the validator Javascript (by default it operates the most recent distributed script).

$ amphtml-validator --help

  Usage: index [options] <fileOrUrlOrMinus...>

  Validates the files or urls provided as arguments. If "-" is
  specified, reads from stdin instead.

  Options:

    -h, --help                  output usage information
    -V, --version               output the version number
    --validator_js <fileOrUrl>  The Validator Javascript.
      Latest published version by default, or
      dist/validator_minified.js (built with build.py)
      for development.
    --format <color|text|json>  How to format the output.
      "color" displays errors/warnings/success in
              red/orange/green.
      "text"  avoids color (e.g., useful in terminals not
              supporting color).
      "json"  emits json corresponding to the ValidationResult
              message in validator.proto.

Things that turns out if my web page isn't actually valid?

The AMP Validator isn't actually just an advantage for you through production. It's likewise utilized by sites such as Twitter as well as Google which concentrate your AMP web pages inside their web content plus search results page. More so, they normally don't ever get the webpages instantly out of your server but utilise the Google AMP Cache, a free of charge solution which caches your pages and generates them available across the entire world, so that they install actually faster.

In the case that the AMP affirmation support service finds that there is possibly something incorrect with your page, it will not get found and promoted by 3rd party websites and will not show up around the Google AMP Cache. On this wise certainly not only you might lose the speed advantages of the cache, it's most likely that your page will not be observed in numerous sources! That would be a shame, so let's ensure that it doesn't come about.

How do I fix AMP validator mistakes?

A large number of authorizing mistakes are easy to focus on and take care of. Look at this HTML tag:

<div class="img"><img src="cat.png"></div>

Which produces this kind of AMP affirmation fault, demonstrated in these several tools:

- AMP validator Internet browser Developer Console

- AMP validator online interface

- AMP validator browser extension

Every instrument gives a number of components of relevant information:

1. The place (line and column) in the HTML document precisely where the mistake came about, clickable in a couple of user interfaces to highlight that place. In this particular situation, the problem takes place on line 11, column 2.

2. A line of text illustrating the mistake. Within this case the message shows that we are simply applying an <div class="img"><img></div> tag, when we should have applied an <amp-img> tag.

3. A web link to a related document relating to the problem. Within this case the documentation to the <amp-img> tag. Not actually all problems create documentation hyperlinks.

Properly re-reading the specifications, we know that we are using an <div class="img"><img></div> tag, although we should have used an <amp-img> tag. To even better understand the full listing of possible glitches, notice the AMP Validation Errors overview on their formal website.

Final thoughts

Basically, these are the easiest and convenient ways you can easily use to check if the pages you've been working on are so far AMP complaint and get some hints what to do if so far they need a bit of a touch to fit the standard.

Examine a number of video clip guide about AMP validations:

Connected topics:

AMP validation - main records

Official web page of AMP validator

AMP Google Search Console Validation - issue on Stackoverflow

Best Free AI Website Builder

Generate AI websites with a simple prompt! Type in any language, export in zip.


AI Website Builder



Best Free Website Builder Software

Create awesome websites offline! No coding. 9900+ templates. Edit and save locally, upload wherever.


Free website builder download for Win, Mac, Linux!



Latest Posts

  1. AI Website Creators and Generators - Reviewed & Tested .
  2. AI website maker and generator - experience the future of website creation with AI .
  3. Free AI website generator and creator - create a website design with AI.
  4. Best Website Builder AIBest Free AI Website Builder - Create Website with AI
  5. Best Website Builder for Interior Designs, Digital Marketing Agencies, Travel Agencies
  6. Best Website Builder for Churches, Authors, Consultants, Magazines
  7. Website Builder for Education, Software Companies, Designers, Videos
  8. Website Builder for Beginners, Bloggers, Writers, IT Companies
  9. Website Builder for Online Stores, Restaurants, Musicians, Real Estate
  10. Podcasts and affiliate marketing Website Builder
  11. Best Website Builder For therapists and nonprofits
  12. Website Builder For SEO and portfolio
  13. Best Website Builder For Kids & Musicians
  14. Photographer & Artist Website Builder
  15. HTML Code Generator - HTML Code Generator
  16. Web Design Tool - Web Design Program
  17. Landing Page Maker - Landing Page Generator
  18. Easiest Website Builder For Beginners - No Coding Website Builder
  19. Fantastic HTML Constructor with Drag and Drop or Full Code Editor
  20. Eye-catching HTML Generator You Should Try
  21. Best QR Code Generator Free
  22. Top 11 Wix App Alternative Website Builders
  23. Top 11 Free Wordpress Alternatives Services
  24. Instagram Feed Embed
  25. Really Convenient Business Website Builder Overview
  26. AMP format overview
  27. amp-live-list AMP Blog component
  28. AMP Layout & Media queries
  29. Image galleries and AMP
  30. AMP Font
  31. Using AMP with Bootstrap
  32. AMP SEO
  33. AMP and Wordpress
  34. Facebook Instant Articles vs. Google AMP
  35. AMP Form - amp-form extended examples and tricks
  36. AMP Analytics
  37. AMP Carousel, amp-carousel advanced examples and tricks
  38. AMP AD
  39. AMP HTML Advanced Examples, Codes, Tags
  40. AMP IFrame - amp-iframe examples and tricks
  41. What is AMP? - Overview