You are here

README.txt in Schema.org Metatag 7

Same filename and directory in other branches
  1. 8.2 README.txt
  2. 8 README.txt
Schema.org Metatag
--------------------------------------------------------------------------------
This project extends Drupal's Metatag module to display structured data as
JSON-LD in the head of web pages. Either hard-code properties or identify
patterns using token replacements. Using the override system in Metatag module
you can define default structured data values for all content types, override
the global content defaults for a particular content type, or even override
everything else on an individual node to provide specific values for that node.

Read more about Schema.org, JSON-LD, and how this module works in an article on
Lullabot.com:
Create SEO Juice From JSON LD Structured Data in Drupal
https://www.lullabot.com/articles/create-seo-juice-by-adding-json-ld-structured-data-to-drupal-8.

Since the Schema.org [1] list is huge, and growing, this module only provides a
small subset of those values, but it is designed to be extensible. Several types
are included which can be copied to add new types (groups) with any number of
their own properties.

The module creates the following Schema.org object types:

Schema.org/Article
Schema.org/Event
Schema.org/ItemList (for Views)
Schema.org/Organization
Schema.org/VideoObject
Schema.org/WebPage
Schema.org/WebSite


Requirements
--------------------------------------------------------------------------------
The Metatag module is required:
https://www.drupal.org/project/metatag

This module requires PHP 5.5, it will not work with older versions of PHP.


Validation
--------------------------------------------------------------------------------
For more information and to test the results:
- https://developers.google.com/search/docs/guides/intro-structured-data
- https://schema.org/docs/full.html
- https://search.google.com/structured-data/testing-tool

If you are new to structured data you should definitely read the first reference
carefully.

For more information about the Metatag module and how to set it up, see
https://www.drupal.org/docs/7/modules/metatag.


Known Issues
--------------------------------------------------------------------------------
- The Drupal 7 Zen and Mothership themes strip out part of the JSON LD element,
  invalidating the result. Use a different theme or see these issues:
  https://www.drupal.org/project/zen/issues/2934644
  https://www.drupal.org/project/mothership/issues/2942341

- To populate the image width and height properties, use the appropriate tokens.
  It is recommended need to use the Imagecache Token module [2], which provides
  the tokens for image dimensions which are missing in Drupal 7.


Development Instructions
--------------------------------------------------------------------------------
This module defines Metatag groups that map to Schema.org types, and Metatag
tags for Schema.org properties, then steps in before the values are rendered as
metatags, pulls the Schema.org values out of the header created by Metatag, and
instead renders them as JSON-LD when the page is displayed.

The module includes a base group class and several base tag classes that can be
extended. Many properties are simple key/value pairs that require nothing more
than extending the base class and giving them their own ids. Some are more
complex, like Person and Organization, and BreadcrumbList, and they collect
multiple values and serialize the results.

The development process for adding groups and properties:

- Create a file MODULE_NAME.metatag.inc and define the groups and properties
  there. The $info array allows you to indicate a class for each property, where
  you can use the appropriate base class.

In either case, you should be able to copy one of the existing modules as a
starting point.


Examples
--------------------------------------------------------------------------------
Using this module, the code in the head might end up looking like this:

<code>
<script type="application/ld+json">{
    "@context": "https://schema.org",
    "@graph": [
        {
            "@type": "Article",
            "description": "Curabitur arcu erat.",
            "datePublished": "2009-11-30T13:04:01-0600",
            "dateModified": "2017-05-17T19:02:01-0500",
            "headline": "Curabitur arcu erat]",
            "author": {
                "@type": "Person",
                "name": "Minney Mouse",
                "sameAs": "https://example.com/user/2"
            },
            "publisher": {
                "@type": "Organization",
                "name": "Example.com",
                "sameAs": "https://example.com/",
                "logo": {
                    "@type": "ImageObject",
                    "url": "https://example.com/sites/default/files/logo.png",
                    "width": "600",
                    "height": "60"
                }
            },
            "mainEntityOfPage": {
                "@type": "WebPage",
                "@id": "https://example.com/story/example-story"
            },
        },
    ]
}</script>
</code>


Credits
--------------------------------------------------------------------------------
The initial development was by Karen Stevenson [2].


References
--------------------------------------------------------------------------------
1: https://schema.org/
2: https://www.drupal.org/project/imagecache_token
3: https://www.drupal.org/u/karens

File

README.txt
View source
  1. Schema.org Metatag
  2. --------------------------------------------------------------------------------
  3. This project extends Drupal's Metatag module to display structured data as
  4. JSON-LD in the head of web pages. Either hard-code properties or identify
  5. patterns using token replacements. Using the override system in Metatag module
  6. you can define default structured data values for all content types, override
  7. the global content defaults for a particular content type, or even override
  8. everything else on an individual node to provide specific values for that node.
  9. Read more about Schema.org, JSON-LD, and how this module works in an article on
  10. Lullabot.com:
  11. Create SEO Juice From JSON LD Structured Data in Drupal
  12. https://www.lullabot.com/articles/create-seo-juice-by-adding-json-ld-structured-data-to-drupal-8.
  13. Since the Schema.org [1] list is huge, and growing, this module only provides a
  14. small subset of those values, but it is designed to be extensible. Several types
  15. are included which can be copied to add new types (groups) with any number of
  16. their own properties.
  17. The module creates the following Schema.org object types:
  18. Schema.org/Article
  19. Schema.org/Event
  20. Schema.org/ItemList (for Views)
  21. Schema.org/Organization
  22. Schema.org/VideoObject
  23. Schema.org/WebPage
  24. Schema.org/WebSite
  25. Requirements
  26. --------------------------------------------------------------------------------
  27. The Metatag module is required:
  28. https://www.drupal.org/project/metatag
  29. This module requires PHP 5.5, it will not work with older versions of PHP.
  30. Validation
  31. --------------------------------------------------------------------------------
  32. For more information and to test the results:
  33. - https://developers.google.com/search/docs/guides/intro-structured-data
  34. - https://schema.org/docs/full.html
  35. - https://search.google.com/structured-data/testing-tool
  36. If you are new to structured data you should definitely read the first reference
  37. carefully.
  38. For more information about the Metatag module and how to set it up, see
  39. https://www.drupal.org/docs/7/modules/metatag.
  40. Known Issues
  41. --------------------------------------------------------------------------------
  42. - The Drupal 7 Zen and Mothership themes strip out part of the JSON LD element,
  43. invalidating the result. Use a different theme or see these issues:
  44. https://www.drupal.org/project/zen/issues/2934644
  45. https://www.drupal.org/project/mothership/issues/2942341
  46. - To populate the image width and height properties, use the appropriate tokens.
  47. It is recommended need to use the Imagecache Token module [2], which provides
  48. the tokens for image dimensions which are missing in Drupal 7.
  49. Development Instructions
  50. --------------------------------------------------------------------------------
  51. This module defines Metatag groups that map to Schema.org types, and Metatag
  52. tags for Schema.org properties, then steps in before the values are rendered as
  53. metatags, pulls the Schema.org values out of the header created by Metatag, and
  54. instead renders them as JSON-LD when the page is displayed.
  55. The module includes a base group class and several base tag classes that can be
  56. extended. Many properties are simple key/value pairs that require nothing more
  57. than extending the base class and giving them their own ids. Some are more
  58. complex, like Person and Organization, and BreadcrumbList, and they collect
  59. multiple values and serialize the results.
  60. The development process for adding groups and properties:
  61. - Create a file MODULE_NAME.metatag.inc and define the groups and properties
  62. there. The $info array allows you to indicate a class for each property, where
  63. you can use the appropriate base class.
  64. In either case, you should be able to copy one of the existing modules as a
  65. starting point.
  66. Examples
  67. --------------------------------------------------------------------------------
  68. Using this module, the code in the head might end up looking like this:
  69. Credits
  70. --------------------------------------------------------------------------------
  71. The initial development was by Karen Stevenson [2].
  72. References
  73. --------------------------------------------------------------------------------
  74. 1: https://schema.org/
  75. 2: https://www.drupal.org/project/imagecache_token
  76. 3: https://www.drupal.org/u/karens