3 This module allows a site's builder to automatically provide structured
4 metadata, aka "meta tags", about the site and individual pages.
6 In the context of search engine optimization, providing an extensive set of
7 meta tags may help improve the site's and pages' rankings, thus may aid with
8 achieving a more prominent display of the content within search engine results.
9 They can also be used to tailor how content is displayed when shared on social
12 For additional information, see the online documentation:
13 https://www.drupal.org/docs/8/modules/metatag
15 This version should work with all Drupal 8 releases, though it is always
16 recommended to keep Drupal core installations up to date.
20 --------------------------------------------------------------------------------
21 Metatag for Drupal 8 requires the following:
24 https://www.drupal.org/project/token
25 Provides a popup browser to see the available tokens for use in meta tag
30 --------------------------------------------------------------------------------
31 The primary features include:
33 * An administration interface to manage default meta tags.
35 * Use of standard fields for entity support, allowing for translation and
36 revisioning of meta tag values added for individual entities.
38 * A large volume of meta tags available, covering commonly used tags, Open
39 Graph tags, Twitter Cards tags, Dublin Core tags, Google+ tags, App Links
40 tags, site verification tags and more; all but the basic meta tags are kept
41 in separate submodules.
43 * The fifteen Dublin Core Basic Element Set 1.1 meta tags may be added by
44 enabling the "Metatag: Dublin Core" submodule.
46 * Forty additional Dublin Core meta tags may be added by enabling the "Metatag:
47 Dublin Core Advanced" submodule.
49 * The Open Graph Protocol meta tags, as used by Facebook, Pinterest, LinkedIn
50 and other sites, may be added by enabling the "Metatag: Open Graph" submodule.
52 * The Twitter Cards meta tags may be added by enabling the "Metatag: Twitter
55 * Certain meta tags used by Google+ may be added by enabling the "Metatag:
58 * Facebook's fb:app_id, fb:admins and fb:pages meta tags may be added by
59 enabling the "Metatag: Facebook" submodule. These are useful for sites which
60 are using Facebook widgets or are building custom integration with Facebook's
61 APIs, but they are not needed by most sites and have no bearing on the
64 * The Pinterest meta tags may be added by enabling the "Metatag: Pinterest"
67 * Site verification meta tags can be added, e.g. as used by the Google search
68 engine to confirm ownership of the site; see the "Metatag: Verification"
71 * The Metatag: Mobile & UI Adjustments submodule adds the MobileOptimized,
72 HandheldFriendly, viewport, cleartype, theme-color, format-detection,
73 apple-mobile-web-app-capable, apple-mobile-web-app-status-bar-style, the
74 android-app and ios-app alternative link meta tags, and the Android manifest
77 * The hreflang meta tags are available via the Metatag:hreflang submodule.
79 * The App Links meta tags may be added by enabling the Metatag: App Links
82 * Support for meta tags specific to Google Custom Search Appliance are available
83 in the "Metatag: Google Custom Search Engine (CSE)" submodule.
85 * Meta tags specific to Facebook are included in the "Metatag: Facebook"
88 * A plugin interface allowing for additional meta tags to be easily added via
91 * Integration with DrupalConsole [1] to provide a quick method of generating new
95 Standard usage scenario
96 --------------------------------------------------------------------------------
97 1. Install the module.
98 2. Open admin/config/search/metatag.
99 3. Adjust global and entity defaults. Fill in reasonable default values for any
100 of the meta tags that need to be customized. Tokens may be used to
101 automatically assign values.
102 4. Additional bundle defaults may be added by clicking on "Add metatag
103 defaults" and filling out the form.
104 5. To adjust meta tags for a specific entity, the Metatag field must be added
105 first. Follow these steps:
107 5.1 Go to the "Manage fields" of the bundle where the Metatag field is to
109 5.2 Select "Meta tags" from the "Add a new field" selector.
110 5.3 Fill in a label for the field, e.g. "Meta tags", and set an appropriate
111 machine name, e.g. "meta_tags".
112 5.4 Click the "Save and continue" button.
113 5.5 If the site supports multiple languages, and translations have been
114 enabled for this entity, select "Users may translate this field" to use
115 Drupal's translation system.
118 Simplify the content administration experience
119 --------------------------------------------------------------------------------
120 This module and its submodules gives a site's content team the ability to add
121 every meta tag ever. The standard meta tag form added by the Metatag field on
122 content entities can be overwhelming to content creators and editors who just
123 need to manage a few options.
125 The easiest way of simplifying this for content teams is to add new fields to
126 the content type for the meta data fields that are needed and skip adding the
127 Metatag field entirely, then use tokens for those fields in the defaults
128 (/admin/config/search/metatag). These fields can be used in the entity's
129 display, or just left hidden.
132 Alternative option to simplify the content administration experience
133 --------------------------------------------------------------------------------
134 On the settings page (/admin/config/search/metatag/settings) are options to
135 control which meta tag groups are available for each entity bundle. This allows
136 e.g. the Favicon meta tags to be available for global configurations but to hide
137 them on entity forms.
140 Programmatically assign meta tags to an entity
141 --------------------------------------------------------------------------------
142 There are two ways to assign an entity's meta tags in custom module. Both
143 scenarios require a "Metatag" field be added to the entity's field settings, the
144 field name "field_meta_tags" is used but this is completely arbitrary.
148 $entity_type = 'node';
152 'title' => 'Testing metatag creation',
155 'field_meta_tags' => serialize([
156 'title' => 'Some title',
157 'description' => 'Some description.',
158 'keywords' => 'Some,Keywords',
161 $node = \Drupal::entityTypeManager()
162 ->getStorage($entity_type)
168 $node = Node::create([
174 $node->set('title', 'Testing metatag creation');
175 $node->set('field_meta_tags', serialize([
176 'title' => 'Some title',
177 'description' => 'Some description.',
178 'keywords' => 'Some,Keywords',
182 In both examples, the custom meta tag values will still be merged with the
183 values defined via the global defaults prior to being output - it is not
184 necessary to copy each value to the new record.
187 Obtain meta tags for an entity
188 --------------------------------------------------------------------------------
189 For developers needing to access the rendered meta tags for a given entity, a
190 function is provided to make this easy to do:
192 $metatags = metatag_generate_entity_metatags($entity);
194 This will return an array with the following structure:
201 'content' => 'The What | D8.4',
207 'rel' => 'canonical',
208 'href' => 'http://example.com/what',
214 'name' => 'description',
215 'content' => 'I can't even.',
221 'name' => 'generator',
222 'content' => 'Drupal 8!',
227 The meta tags are keyed off the meta tag plugin's ID, e.g. "generator". Each
228 meta tag is then provided as arguments suitable for use in a render array with
229 the type "html_tag". Extracting the value of the meta tag will depend upon the
230 type of meta tag, e.g. the generator meta tag uses the "content" attribute while
231 the link tag uses the "href" attribute.
234 DrupalConsole integration
235 --------------------------------------------------------------------------------
236 Using the DrupalConsole, it is possible to generate new meta tags, either for
237 use in new custom modules that require custom meta tags, or to create patches
238 for extending Metatag's options.
240 To generate a new tag, install DrupalConsole and then use the following command:
242 drupal generate:plugin:metatag:tag
244 This will guide the site builder through the necessary steps to create a new
245 meta tag plugin and add it to a module.
247 There is also a command for generating meta tag groups:
249 drupal generate:plugin:metatag:group
251 Again, this provides a guided process to create a new group.
255 --------------------------------------------------------------------------------
256 Some modules are available that extend Metatag with additional or complimentary
260 https://www.drupal.org/project/schema_metatag
261 Extensive solution for adding schema.org / JSON-LD support to Metatag.
264 https://www.drupal.org/project/context_metadata
265 Allow assignment of meta tags based upon different system contexts, e.g. per
268 * Real-time SEO for Drupal
269 https://www.drupal.org/project/yoast_seo
270 Uses the YoastSEO.js library and service (https://yoast.com/) to provide
271 realtime feedback on the meta tags.
274 https://www.drupal.org/project/metatag_cxense
275 Adds support for the Cxense meta tags used by their DMP and Insight services.
277 * Metatag Google Scholar
278 https://www.drupal.org/project/metatag_google_scholar
279 Adds support for a number of meta tags used with the Google Scholar system.
283 --------------------------------------------------------------------------------
284 * In order to uninstall the module any "Metatag" fields must first be removed
285 from all entities. In order to see whether there are fields blocking the
286 module from being uninstalled, load the module uninstall page
287 (admin/modules/uninstall) and see if any are listed, it will look something
289 The Meta tags field type is used in the following field:
291 In order to uninstall the module, go to the appropriate field settings pages
292 and remove the Metatag field listed in the message. Once this is done it will
293 be possible to uninstall the module.
297 --------------------------------------------------------------------------------
298 Currently maintained by Damien McKenna [2] and Dave Reid [3]. Drupal 7 module
299 originally written by Dave Reid. Early work on Drupal 8 port by Damien McKenna
300 and Michelle Cox [4], and sponsored by Mediacurrent [5]; key improvements by
301 Juampy Novillo Requena [6] with insights from Dave Reid and sponsorship by
302 Lullabot [7] and Acquia [8]. Additional contributions to the 8.x-1.0 release
303 from cilefen [9], Daniel Wehner [10], Jesus Manuel Olivas [11], Lee Rowlands
304 [12], Michael Kandelaars [13], Ivo Van Geertruyen [14], Nikhilesh Gupta B [15],
305 Rakesh James [16], and many others.
307 Ongoing development is sponsored by Mediacurrent.
309 The best way to contact the authors is to submit an issue, be it a support
310 request, a feature request or a bug report, in the project issue queue:
311 https://www.drupal.org/project/issues/metatag
315 --------------------------------------------------------------------------------
316 1: https://www.drupal.org/project/console
317 2: https://www.drupal.org/u/damienmckenna
318 3: https://www.drupal.org/u/dave-reid
319 4: https://www.drupal.org/u/michelle
320 5: https://www.mediacurrent.com/
321 6: https://www.drupal.org/u/juampynr
322 7: https://www.lullabot.com/
323 8: https://www.acquia.com/
324 9: https://www.drupal.org/u/cilefen
325 10: https://www.drupal.org/u/dawehner
326 11: https://www.drupal.org/u/jmolivas
327 12: https://www.drupal.org/u/larowlan
328 13: https://www.drupal.org/u/mikeyk
329 14: https://www.drupal.org/u/mr.baileys
330 15: https://www.drupal.org/u/nikhilesh-gupta
331 16: https://www.drupal.org/u/rakeshgectcr