RDFa (or Resource Description Framework – in – attributes) is a W3C Recommendation which allows embedding metadata within Web documents. Drupal 7 outputs RDFa data in core. The following changes are required to your theme to be valid RDFa:
- The DOCTYPE must be changed to XHTML+RDFa 1.0.
- The old
lang
attribute should be removed for compatibility with XHTML 1.1, onlyxml:lang
should remain. - The RDF namespace prefixes used throughout the HTML document need to be serialized in the
html
tag and are contained in the$rdf_namespaces
variable. - The GRDDL profile should be specified in the
<head>
tag.
Drupal 6.x (page.tpl.php)
In Drupal 6, you need to edit page.tpl.php and use this snippet:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language; ?>" version="XHTML+RDFa 1.0" dir="<?php print $language->dir; ?>"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:og="http://ogp.me/ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:sioc="http://rdfs.org/sioc/ns#"
xmlns:sioct="http://rdfs.org/sioc/types#"
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>
<head profile="http://www.w3.org/1999/xhtml/vocab">
You can add more namespace definitions depending on what vocabularies your site uses.
Drupal 7.x (html.tpl.php)
Drupal 7 is RDFa aware and will populate the $rdf_namespace
and $grddl_profile
variables which you can insert in html.tpl.php. Note that in most cases, you probably won't need to override the default html.tpl.php provided by the system module. In case you do, use this snippet:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>"
<?php print $rdf_namespaces ?>>
<head profile="<?php print $grddl_profile ?>">