Something went wrong while trying to load more search results. Mustache edge up.
We apologize for the inconvenience caused.
Valid AMP documents must not include any validation errors. The purpose of this document is to help you better understand and fix any validation errors you encounter when you validate your AMP pages. For a complete overview of the validation errors, see the AMP validator specification.
AMP HTML tag and attribute errors
Mandatory tag missing
The following tags must be present in all AMP docs:
<link rel="canonical" href="$SOME_URL">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script async src="https://cdn.ampproject.org/v0.js"></script>
These mandatory tags include a
Tag required by another tag is missing
The validator throws the
error when it finds an extended component in the AMP document, but doesn't find its equivalent
Extended components must be explicitly included in the AMP document as custom elements. To fix these errors, navigate to the extended component's reference page, copy its required script, and paste it into the AMP document
Disallowed tag
Tags are whitelisted, so there is no definitive list of all disallowed tags; however, the AMP specification broadly defines the set of disallowed tags.
Custom JavaScript is not allowed
The AMP format does not allow custom JavaScript to be added to pages, except for JavaScript files provided by the AMP Project itself. Many common uses of JavaScript have AMP HTML library equivalent implementations. See AMP components for the set of components that can be used to enhance AMP HTML pages.
If your use case is not covered, you may also consider contributing new components to the AMP Project. See the AMP Project's contributing document for more information.
Mandatory attribute missing
Mandatory attributes for AMP tags are defined within AMP's validator spec. Simply search for the tag, view the listed attributes, and check for
. Mandatory attributes for each AMP tag are also listed within the tag's specification.
Invalid attribute value
This error indicates that an HTML tag has an attribute with an allowed name, but not an allowed value. For example, one common trigger for this error is invalid values for URLs. All URLs values (in
IMPORTANT: Many URL values in AMP require HTTPS. If you are getting this error, and aren't sure why, check the relevant AMP tag's specification to see if the attribute requires HTTPS.
Disallowed attribute
Attributes are whitelisted, so there is no definitive list of all disallowed attributes. To check the supported attributes for each specific tag, search for HTML tag, and then
In addition to a whitelist of specific attributes for each tag, all AMP tags can use any of the attributes white-listed under
; all attributes with a prefix of
Mandatory text missing or incorrect
CDATA is the content data between a start and end HTML tag and is currently evaluated with both whitelists and blacklists. Tags with mandatory CDATA include:
Detailed messages for this can be one of the following:
"Mandatory style boilerplate (js enabled)"
"Mandatory style boilerplate (noscript)"
"Disallowed -amp- CSS class name prefix"
"Disallowed!important attribute in CSS"
Mustache options
"Disallowed @charset in CSS"
"Disallowed @import in CSS"
"Disallowed @namespace in CSS"
"Disallowed @supports in CSS"
"Disallowed @document in CSS"
"Disallowed @viewport in CSS"
Disallowed text inside tag
Specific CSS data has been blacklisted to validate essential CSS AMP rules.
The following is the list of blacklisted CSS data (see also
blacklisted_cdata_regex
in the AMP validator spec ):
("CSS -amp- class name prefix")
Disallowed property inside attribute in tag
This error occurs when the property name inside an attribute is not allowed. The term property in this context means the structured key/value data inside an attribute.
For example, the following would result in an error:
<meta http-equiv="X-UA-Compatible" content="invalidfoo=edge">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="viewport content="width=device-width;minimum-scale=1">
The following results in a DISALLOWED_PROPERTY_IN_ATTR_VALUE error:
<meta name="viewport content="width=device-width;invalidfoo=1">
Invalid property value
This error occurs when the property value inside an attribute is invalid. The term property in this context means the structured key/value data inside an attribute.
<meta name="viewport content="width=device-width;minimum-scale=1">
The following results in a INVALID_PROPERTY_VALUE_IN_ATTR_VALUE error:
<meta name=viewport content="width=device-width;minimum-scale=invalidfoo">
Note, if you're attempting to output a valueless attribute (for example, an attribute such as
, etc.) component), but your HTML build process is generating a default (but invalid) value such as
(React, for example, will produce
by default ), the workaround is to output the attribute's name as the value. For example,
Missing URL
This error occurs when an attribute that requires a URL is missing it, for example, an empty
Invalid URL
This error occurs when a attribute has a URL, but the URL is invalid.
Invalid URL protocol
This error occurs for tags that have an
that must be set to certain protocols. For example, many tags require
Mandatory property missing from attribute
Currently, this error occurs if these mandatory properties are missing:
They refer to expected tags:
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name=viewport content="width=device-width;minimum-scale=1">
Mutually exclusive attributes
This error occurs when a tag has both of the mutually exclusive attributes. For example, only one is allowed for the following tags:
Missing mandatory attribute from list
This error occurs when a tag is missing one required attribute from multiple choices. For example, these tags require one attribute from two possible choices:
Wrong parent tag
Specific tags require an immediate parent (as opposed to distant ancestor). The following lists the required parent for specific tags (tag, parent):
Disallowed tag ancestor
This error occurs when a tag is a descendant of another tag which doesn't validate. Currently, the only example is a
tag, which may not be nested under another
Mandatory tag ancestor
The error occurs when the following tags are missing their
Mandatory tag ancestor with hint
The error occurs when one of the following tags is found in the AMP document, and isn't properly nested in its mandatory parent:
Duplicate unique tag
This error occurs when exactly one instance of the tag is allowed, and a duplicate is found.
The full list of unique tags is known:
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<script src="https://cdn.ampproject.org/v0.js">
Style and layout errors
Before diving into style and layout errors, it's worth understanding how styling and layout work in AMP. Since AMP pages are HTML pages, styling is very much the same as any HTML page. But there are some restrictions to ensure pages load fast, and the AMP validator enforces these restrictions.
Layout is more controlled in AMP pages. Any tag that gets displayed on the page requires a pre-defined height and width, significantly reducing rendering and scrolling jank. This doesn't mean that you have to manually include these attributes. For certain layout types, the AMP validator won't throw errors as default values are assumed.
, as defined in the AMP validator specification. The validator will throw errors for unsupported layouts, and it will check validation rules for the pre-defined layout.
Stylesheet too long
The AMP validator throws this error when it measures the size of the styles content within
to exceed the 50,000 bytes limit.
CSS syntax error
This error occurs when you've CSS syntax errors in the specified tag. If you aren't sure what's causing the error, try running the CSS through an online CSS validator, for example, csslint.
CSS syntax error at specific rule
This error refers to the @-rules within CSS, for which AMP only allows a handful of rules. (see also the AMP specification ). For example,
Different kinds of beards and mustaches
isn't allowed. The validation error specifically tells you the rule that's invalid, making it easier to fix that rule.
Implied layout isn't supported by AMP tag
This error occurs when you don't specify a layout for the AMP tag, and the implied layout (based on width, height, and sizes) isn't supported. Check the
Actual layout behavior is determined by the
Attribute not allowed by implied layout
This error occurs when you don't specify a layout for the AMP tag, and the implied layout contains a disallowed attribute. Disallowed attributes for layout types are described in the AMP HTML layout system specification.
Specified layout isn't supported by AMP tag
This error occurs when the specified layout for the tag isn't supported. Check the
Actual layout behavior is determined by the
Attribute not allowed by specified layout
This error occurs when you specify a layout for the AMP tag, and the layout contains a disallowed attribute. Disallowed attributes for layout types are described in the AMP HTML layout system specification.
Invalid value for attribute required by layout
This error occurs when the attribute value is invalid for the specified layout. To understand what triggers this error, you need to familiarize yourself with the different behaviors of layouts.
Let's say you set the layout to be
and you include numeric values for both
attribute must not be present or else set to
. The validator throws the ATTR_VALUE_REQUIRED_BY_LAYOUT.
Inconsistent units for width and height
, width and height attributes need to be expressed in the same units. When they are not, this error is triggered.
<amp-img src="" layout="responsive" width="42px" height="42rem">
, results in this error message:
"Inconsistent units for width and height in tag '
- width is specified in 'px' whereas height is specified in 'rem'."
Templating errors
AMP pages can't include templating syntax, unless that syntax is within an AMP tag specifically designed to include templates, for example,
It's OK to include templates in your source files, so long as the generated output of those files doesn't contain the templates (see also Use CSS preprocessors ).
Attribute contains template syntax
This error occurs anytime the validator finds Mustache template syntax in an attribute value.
Attribute contains unescaped template syntax
Attribute contains template partial
This error occurs anytime the validator finds a Mustache partial in an attribute value.
Deprecation errors
Deprecated tag
This warning occurs when a previously valid AMP tag is found in the AMP document. It's only a warning; AMP documents with warnings continue to be valid. Currently no deprecated tags exist; the warning is reserved for future deprecations.
Deprecated attribute
This warning occurs when a previously valid AMP attribute is found in the AMP document. It's only a warning; AMP documents with warnings continue to be valid.
Identify deprecated attributes for each AMP tag by searching for
Comments
There are no comments for this post "AMP validation errors -". Be the first to comment...
Add Comment