4f7da51328f716a509cbad0d5c2fe86b40478c85
[yaffs-website] / web / modules / contrib / metatag / README.txt
1 Metatag
2 -------
3 This module allows a site's builder to automatically provide structured
4 metadata, aka "meta tags", about the site and individual pages.
5
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
10 networks.
11
12 For additional information, see the online documentation:
13   https://www.drupal.org/docs/8/modules/metatag
14
15 This version should work with all Drupal 8 releases, though it is always
16 recommended to keep Drupal core installations up to date.
17
18
19 Requirements
20 --------------------------------------------------------------------------------
21 Metatag for Drupal 8 requires the following:
22
23 * Token
24   https://www.drupal.org/project/token
25   Provides a popup browser to see the available tokens for use in meta tag
26   fields.
27
28
29 Features
30 --------------------------------------------------------------------------------
31 The primary features include:
32
33 * An administration interface to manage default meta tags.
34
35 * Use of standard fields for entity support, allowing for translation and
36   revisioning of meta tag values added for individual entities.
37
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.
42
43 * The fifteen Dublin Core Basic Element Set 1.1 meta tags may be added by
44   enabling the "Metatag: Dublin Core" submodule.
45
46 * Forty additional Dublin Core meta tags may be added by enabling the "Metatag:
47   Dublin Core Advanced" submodule.
48
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.
51
52 * The Twitter Cards meta tags may be added by enabling the "Metatag: Twitter
53   Cards" submodule.
54
55 * Certain meta tags used by Google+ may be added by enabling the "Metatag:
56   Google+" submodule.
57
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
62   Open Graph meta tags.
63
64 * The Pinterest meta tags may be added by enabling the "Metatag: Pinterest" 
65   submodule.
66
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"
69   submodule.
70
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
75   tag.
76
77 * The hreflang meta tags are available via the Metatag:hreflang submodule.
78
79 * The App Links meta tags may be added by enabling the Metatag: App Links
80   submodule.
81
82 * Support for meta tags specific to Google Custom Search Appliance are available
83   in the "Metatag: Google Custom Search Engine (CSE)" submodule.
84
85 * Meta tags specific to Facebook are included in the "Metatag: Facebook"
86   submodule.
87
88 * A plugin interface allowing for additional meta tags to be easily added via
89   custom modules.
90
91 * Integration with DrupalConsole [1] to provide a quick method of generating new
92   meta tags.
93
94
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:
106
107    5.1 Go to the "Manage fields" of the bundle where the Metatag field is to
108        appear.
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.
116
117
118 Programmatically assign meta tags to an entity
119 --------------------------------------------------------------------------------
120 There are two ways to assign an entity's meta tags in custom module. Both
121 scenarios require a "Metatag" field be added to the entity's field settings, the
122 field name "field_meta_tags" is used but this is completely arbitrary.
123
124 Option 1:
125
126   $entity_type = 'node';
127   $values = [
128     'nid' => NULL,
129     'type' => 'article',
130     'title' => 'Testing metatag creation',
131     'uid' => 1,
132     'status' => TRUE,
133     'field_meta_tags' => serialize([
134       'title' => 'Some title',
135       'description' => 'Some description.',
136       'keywords' => 'Some,Keywords',
137     ]),
138   ];
139   $node = \Drupal::entityTypeManager()
140     ->getStorage($entity_type)
141     ->create($values);
142   $node->save();
143
144 Option 2:
145
146   $node = Node::create([
147     'type' => article,
148     'langcode' => 'en',
149     'status' => 1,
150     'uid' => 1,
151   ]);
152   $node->set('title', 'Testing metatag creation');
153   $node->set('field_meta_tags', serialize([
154     'title' => 'Some title',
155     'description' => 'Some description.',
156     'keywords' => 'Some,Keywords',
157   ]));
158   $node->save();
159
160 In both examples, the custom meta tag values will still be merged with the
161 values defined via the global defaults prior to being output - it is not
162 necessary to copy each value to the new record.
163
164
165 Obtain meta tags for an entity
166 --------------------------------------------------------------------------------
167 For developers needing to access the rendered meta tags for a given entity, a
168 function is provided to make this easy to do:
169
170   $metatags = metatag_generate_entity_metatags($entity);
171
172 This will return an array with the following structure:
173
174   [
175     'title' => [
176       '#tag' => 'meta',
177       '#attributes' => [
178         'name' => 'title',
179         'content' => 'The What | D8.4',
180       ],
181     ],
182     'canonical_url' => [
183       '#tag' => 'link',
184       '#attributes' => [
185         'rel' => 'canonical',
186         'href' => 'http://example.com/what',
187       ],
188     ],
189     'description' => [
190       '#tag' => 'meta',
191       '#attributes' => [
192         'name' => 'description',
193         'content' => 'I can't even.',
194       ],
195     ],
196     'generator' => [
197       '#tag' => 'meta',
198       '#attributes' => [
199         'name' => 'generator',
200         'content' => 'Drupal 8!',
201       ],
202     ],
203   ]
204
205 The meta tags are keyed off the meta tag plugin's ID, e.g. "generator". Each
206 meta tag is then provided as arguments suitable for use in a render array with
207 the type "html_tag". Extracting the value of the meta tag will depend upon the
208 type of meta tag, e.g. the generator meta tag uses the "content" attribute while
209 the link tag uses the "href" attribute.
210
211
212 DrupalConsole integration
213 --------------------------------------------------------------------------------
214 Using the DrupalConsole, it is possible to generate new meta tags, either for
215 use in new custom modules that require custom meta tags, or to create patches
216 for extending Metatag's options.
217
218 To generate a new tag, install DrupalConsole and then use the following command:
219
220   drupal generate:plugin:metatag:tag
221
222 This will guide the site builder through the necessary steps to create a new
223 meta tag plugin and add it to a module.
224
225 There is also a command for generating meta tag groups:
226
227   drupal generate:plugin:metatag:group
228
229 Again, this provides a guided process to create a new group.
230
231
232 Related modules
233 --------------------------------------------------------------------------------
234 Some modules are available that extend Metatag with additional or complimentary
235 functionality:
236
237 * Schema.org Metatag
238   https://www.drupal.org/project/schema_metatag
239   Extensive solution for adding schema.org / JSON-LD support to Metatag.
240
241 * Context Metadata
242   https://www.drupal.org/project/context_metadata
243   Allow assignment of meta tags based upon different system contexts, e.g. per
244   path.
245
246 * Real-time SEO for Drupal
247   https://www.drupal.org/project/yoast_seo
248   Uses the YoastSEO.js library and service (https://yoast.com/) to provide
249   realtime feedback on the meta tags.
250
251 * Metatag Cxense
252   https://www.drupal.org/project/metatag_cxense
253   Adds support for the Cxense meta tags used by their DMP and Insight services.
254
255 * Metatag Google Scholar
256   https://www.drupal.org/project/metatag_google_scholar
257   Adds support for a number of meta tags used with the Google Scholar system.
258
259
260 Known issues
261 --------------------------------------------------------------------------------
262 * In order to uninstall the module any "Metatag" fields must first be removed
263   from all entities. In order to see whether there are fields blocking the
264   module from being uninstalled, load the module uninstall page
265   (admin/modules/uninstall) and see if any are listed, it will look something
266   like the following:
267     The Meta tags field type is used in the following field:
268     node.field_meta_tags
269   In order to uninstall the module, go to the appropriate field settings pages
270   and remove the Metatag field listed in the message. Once this is done it will
271   be possible to uninstall the module.
272
273
274 Credits / contact
275 --------------------------------------------------------------------------------
276 Currently maintained by Damien McKenna [2] and Dave Reid [3]. Drupal 7 module
277 originally written by Dave Reid. Early work on Drupal 8 port by Damien McKenna
278 and Michelle Cox [4], and sponsored by Mediacurrent [5]; key improvements by
279 Juampy Novillo Requena [6] with insights from Dave Reid and sponsorship by
280 Lullabot [7] and Acquia [8]. Additional contributions to the 8.x-1.0 release
281 from cilefen [9], Daniel Wehner [10], Jesus Manuel Olivas [11], Lee Rowlands
282 [12], Michael Kandelaars [13], Ivo Van Geertruyen [14], Nikhilesh Gupta B [15],
283 Rakesh James [16], and many others.
284
285 Ongoing development is sponsored by Mediacurrent.
286
287 The best way to contact the authors is to submit an issue, be it a support
288 request, a feature request or a bug report, in the project issue queue:
289   https://www.drupal.org/project/issues/metatag
290
291
292 References
293 --------------------------------------------------------------------------------
294 1: https://www.drupal.org/project/console
295 2: https://www.drupal.org/u/damienmckenna
296 3: https://www.drupal.org/u/dave-reid
297 4: https://www.drupal.org/u/michelle
298 5: https://www.mediacurrent.com/
299 6: https://www.drupal.org/u/juampynr
300 7: https://www.lullabot.com/
301 8: https://www.acquia.com/
302 9: https://www.drupal.org/u/cilefen
303 10: https://www.drupal.org/u/dawehner
304 11: https://www.drupal.org/u/jmolivas
305 12: https://www.drupal.org/u/larowlan
306 13: https://www.drupal.org/u/mikeyk
307 14: https://www.drupal.org/u/mr.baileys
308 15: https://www.drupal.org/u/nikhilesh-gupta
309 16: https://www.drupal.org/u/rakeshgectcr