Search code examples
htmlamp-html

AMP: The mandatory text (CDATA) inside tag 'head > style[amp-boilerplate]' is missing or incorrect, when using AMP's provided sample code


I'm trying to create an AMP page using this tutorial and all sample code. However, when I go to validate my page, I'm seeing these two errors: errors

Every search I've done for this tells me I need to use this exact string, which is already provided in the tutorial: https://github.com/ampproject/amphtml/blob/master/spec/amp-boilerplate.md

My sample code is here: http://pastebin.com/VZ1UEs1q

What am I doing wrong? The only thing I can think of is that my Visual Studio is auto expanding and formatting their 1-liner for the <style> and <noscript> tags.


Solution

  • AMP team member who wrote the linked tutorial here –

    I think your assumption is correct. Go to https://validator.ampproject.org/ and try changing just a single character in the <style amp-boilerplate> content, and you'll see the same error you are seeing.

    The boilerplate code must match exactly – that is, no added line breaks, formatting, anything. I can see how this can be a source of frustration, but a more forgiving check in the validator would be much more expensive (we would have to actually parse the CSS, as opposed to just matching the string).