* The fifteen Dublin Core Basic Element Set 1.1 meta tags may be added by
enabling the "Metatag: Dublin Core" submodule.
+* Forty additional Dublin Core meta tags may be added by enabling the "Metatag:
+ Dublin Core Advanced" submodule.
+
* The Open Graph Protocol meta tags, as used by Facebook, Pinterest, LinkedIn
and other sites, may be added by enabling the "Metatag: Open Graph" submodule.
APIs, but they are not needed by most sites and have no bearing on the
Open Graph meta tags.
+* The Pinterest meta tags may be added by enabling the "Metatag: Pinterest"
+ submodule.
+
* Site verification meta tags can be added, e.g. as used by the Google search
engine to confirm ownership of the site; see the "Metatag: Verification"
submodule.
automatically assign values.
4. Additional bundle defaults may be added by clicking on "Add metatag
defaults" and filling out the form.
-5. To adjust metatags for a specific entity, the Metatag field must be added
+5. To adjust meta tags for a specific entity, the Metatag field must be added
first. Follow these steps:
5.1 Go to the "Manage fields" of the bundle where the Metatag field is to
'keywords' => 'Some,Keywords',
]),
];
- $node = \Drupal::entityTypeManager()->getStorage($entity_type)->create($values);
+ $node = \Drupal::entityTypeManager()
+ ->getStorage($entity_type)
+ ->create($values);
$node->save();
Option 2:
- $node = Node::create(array(
+ $node = Node::create([
'type' => article,
'langcode' => 'en',
'status' => 1,
'uid' => 1,
- ));
+ ]);
$node->set('title', 'Testing metatag creation');
$node->set('field_meta_tags', serialize([
'title' => 'Some title',
necessary to copy each value to the new record.
+Obtain meta tags for an entity
+--------------------------------------------------------------------------------
+For developers needing to access the rendered meta tags for a given entity, a
+function is provided to make this easy to do:
+
+ $metatags = metatag_generate_entity_metatags($entity);
+
+This will return an array with the following structure:
+
+ [
+ 'title' => [
+ '#tag' => 'meta',
+ '#attributes' => [
+ 'name' => 'title',
+ 'content' => 'The What | D8.4',
+ ],
+ ],
+ 'canonical_url' => [
+ '#tag' => 'link',
+ '#attributes' => [
+ 'rel' => 'canonical',
+ 'href' => 'http://example.com/what',
+ ],
+ ],
+ 'description' => [
+ '#tag' => 'meta',
+ '#attributes' => [
+ 'name' => 'description',
+ 'content' => 'I can't even.',
+ ],
+ ],
+ 'generator' => [
+ '#tag' => 'meta',
+ '#attributes' => [
+ 'name' => 'generator',
+ 'content' => 'Drupal 8!',
+ ],
+ ],
+ ]
+
+The meta tags are keyed off the meta tag plugin's ID, e.g. "generator". Each
+meta tag is then provided as arguments suitable for use in a render array with
+the type "html_tag". Extracting the value of the meta tag will depend upon the
+type of meta tag, e.g. the generator meta tag uses the "content" attribute while
+the link tag uses the "href" attribute.
+
+
DrupalConsole integration
--------------------------------------------------------------------------------
Using the DrupalConsole, it is possible to generate new meta tags, either for
Some modules are available that extend Metatag with additional or complimentary
functionality:
-* Schema Metatag
+* Schema.org Metatag
https://www.drupal.org/project/schema_metatag
- Extensive solution for adding schema.org support to Metatag.
+ Extensive solution for adding schema.org / JSON-LD support to Metatag.
+
+* Context Metadata
+ https://www.drupal.org/project/context_metadata
+ Allow assignment of meta tags based upon different system contexts, e.g. per
+ path.
* Real-time SEO for Drupal
https://www.drupal.org/project/yoast_seo
13: https://www.drupal.org/u/mikeyk
14: https://www.drupal.org/u/mr.baileys
15: https://www.drupal.org/u/nikhilesh-gupta
-16: https://www.drupal.org/u/rakeshgectcr
\ No newline at end of file
+16: https://www.drupal.org/u/rakeshgectcr