This module seems to contain some w3c validation errors and warnings (HTML5) that should be resolved. At this moment, inclusion of the metatag module leads to the following html validation errors:
- Error:: Attribute “xmlns:article” not allowed here.
- Info: Attribute with the local name “xmlns:article” is not serializable as XML 1.0.

This error and warning are repeated fivefold for the following attribute values: article, book, product, profile, and video.

These, in turn, appear to be defined in the metatag.module file:
// Namespaces for OpenGraph.
$namespaces['xmlns:article'] = "http://ogp.me/ns/article#";
$namespaces['xmlns:book'] = "http://ogp.me/ns/book#";
$namespaces['xmlns:product'] = "http://ogp.me/ns/product#";
$namespaces['xmlns:profile'] = "http://ogp.me/ns/profile#";
$namespaces['xmlns:video'] = "http://ogp.me/ns/video#";

Thanks,
LaravZ

Comments

LaravZ created an issue. See original summary.

jalpesh’s picture

Any hint, how to solve this?

laravz’s picture

I've found the following discussion.
Apparently, "the only long-term solution is that Facebook needs to create an alternate syntax that is valid HTML5."

However, it could also potentially be solved like this:

For HTML5, add this to your html element like described on ogp.me and keep your og: prefixed property's:

<!doctype html>
<html prefix="og: http://ogp.me/ns#">
<head>
     <meta property="og:type" content="website" />

Not sure whether this is what you're looking for though.

sylus’s picture

StatusFileSize
new3.54 KB

I believe this logic is in the metatag_opengraph submodule in 7.x-1.x so was thinking we could do the same thing for the 8.x-1.x series making this optional for the time being?

Attaching a patch :)

sylus’s picture

Status: Active » Needs review
jalpesh’s picture

I don't know that is right solution or not but by applying path it solve all w3c error . Thanks.

  • DamienMcKenna committed c7466cc on 8.x-1.x authored by sylus
    Issue #2753595 by sylus: Moved the extra XML namespaces to the OpenGraph...
damienmckenna’s picture

Status: Needs review » Fixed
Issue tags: +govcon2016
Parent issue: » #2741339: Plan for Metatag 8.x-1.0-beta10 release

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

sinn’s picture

StatusFileSize
new1011 bytes

Solution from #4 doesn't help pass validation. There are errors:

Attribute xmlns:dc not allowed here.
Attribute xmlns:og not allowed here.
Attribute xmlns:article not allowed here.
Attribute xmlns:book not allowed here.
Attribute xmlns:product not allowed here.
Attribute xmlns:profile not allowed here.
Attribute xmlns:video not allowed here.

But with solution #3 validation is passed.

mfrosch’s picture

@sinn your patch #10 resolved the w3c issues for me - thanks.

damienmckenna’s picture

Status: Closed (fixed) » Needs review

Huh, nice improved syntax. Lets see what the testbot says.

damienmckenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Sorry to throw this at the issue, but I want to a) find documentation that clarifies this is the correct approach to take, b) write a test to confirm the output works as intended.

thejimbirch’s picture

The patch in #10 applies correctly and pages now validate.

Documentation:

On http://ogp.me/#metadata, the basic example shows the og: prefix getting set. <html prefix="og: http://ogp.me/ns#">

Subsequent sections specify the namespace:

music - Namespace URI: http://ogp.me/ns/music#
video - Namespace URI: http://ogp.me/ns/video#
article - Namespace URI: http://ogp.me/ns/article#
book - Namespace URI: http://ogp.me/ns/book#
profile - Namespace URI: http://ogp.me/ns/profile#
website - Namespace URI: http://ogp.me/ns/website#

This blog has a deeper explanation:
https://www.niallkennedy.com/blog/2012/01/open-graph-protocol.html

Semantics
Open Graph protocol 1.1 is based on RDFa Core 1.1 markup. The examples below use compact URI expressions (CURIEs) based on scoped prefixes first defined by a parent element such as .

<head prefix="og: http://ogp.me/ns#">
<meta property="og:title" content="Hello world">
</head>

Tests

Can you point out a test that would have similar functionality that could be used as an example?

karens’s picture

Following this because these elements also invalidate Google AMP pages. I believe the alternate format would pass AMP validation.

zanonmark’s picture

Patch #10 works for me, too.
Please merge it in the official branch.

Thanks,
MZ

dinesh18’s picture

#10 looks good to me. +1 to RTBC

chris2k’s picture

Patch #10 works for me too. +1 to RTBC

suraj2012’s picture

Status: Needs work » Reviewed & tested by the community

patch #10 works for me too.

Marishka_’s picture

+1 for Patch #10. Please merge.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs tests

Fine fine fine :)

Committed.

I've spun off the tests into a new issue: #2992352: Add test coverage for custom HTML from

  • DamienMcKenna committed a94880c on 8.x-1.x authored by sinn
    Issue #2753595 by sinn, thejimbirch: W3C validation error on xmlns...
damienmckenna’s picture

damienmckenna’s picture

damienmckenna’s picture

Title: W3C validation error on xmlns attribute » W3C validation error on xmlns attribute (D8)
damienmckenna’s picture

FYI I opened a new issue for the D7 branch to backport this: #2994102: W3C validation error on xmlns attribute (D7)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.