Why is diazo changing some HTML attributes even if "notheme" applied?

While testing collective.behaviour.amp I realized that amp checks failed because of wrong markup.

The correct rendered HTML output for the amp version of the front page looks like this (when no diazo theme is active):

<!doctype html>
<html amp lang="en">
  <head>
    <meta charset="utf-8">
    <title>Welcome to Plone</title>
    ...

As soon as a diazo theme is active, the rendered HTML looks like this:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" amp="" lang="en" xml:lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta charset="utf-8" />
    <title>Welcome to Plone</title>
    ...

Where is this xmlns coming from? The page should not be themed at all because of <notheme css:if-not-content="#visual-portal-wrapper" />.

I'm using Plone 5.1a2 with the default Barceloneta theme (unchanged).

Are you sure this transformation is done by "diazo"?

I have seen a HTML -> XHTML transformation performed in "plone.protect" (in Plone 4). As "plone.protect" is integrated in Plone 5, it might well be responsible for the transformation in your case as well.

I would say yes. When no diazo theme is active, the rendered HTML is correct. As soon as a theme is enabled, it is transformed (tested on a Plone 5.1a2 site).

Thanks for the hint. I'll take a look into this.

What happens if you try to access the URL appending ?diazo.off=1 or using 127.0.0.1:PORT?
For diazo.off=1 to work, the instance should be in foreground mode.

This should skip the diazo transform, suggesting that some modification is made even if in your rules.xml you have that notheme rule.

You may be interested in disabling diazo theme also by calling: self.request.response.setHeader('X-Theme-Disabled', '1') .

Have fun!

I suppose that the reason is similar as for "plone.protect": one needs to transform the result page and the transformation is easier when at least the target is always XML even if the input has been HTML.

The fun thing is I can't reproduce this error now on my development machine (Mac OS). I have the same packages installed, all the same versions.

The site where I experienced the problem is running on Ubuntu 16.04, using a customization of the ansible playbook for Plone. I'll try the same buildout I have on my local machine on the remote server in the next days to see if there is a difference. Maybe a system package in a different version causing a different transformation, as @dieter already mentioned.

I'm looking for <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />, did you find any hint it is Diazo? If I do ?diazo.off=1, effectively disappear. Should we add this rule to rules.xml?

<drop content="/html/head/meta[@http-equiv='Content-Type']" />

I tested this but the meta tag is still there, maybe Diazo is adding it? Other findings in this post