Drupal 8 Module of the Week: Metatag

jam
February 17, 2016
1
3
Drupal 8 logo

Each day, more Drupal 7 modules are being migrated over to Drupal 8; new modules are also being created for the Drupal community’s latest major release. In this series, the Acquia Developer Center is profiling some of the most prominent, useful modules available for Drupal 8. This week: Metatag.

We reached out to Damien McKenna, a long-time Web developer who came into the Drupal world in 2008, and is now Community Lead at Drupal agency Mediacurrent. The open and supportive community had him hooked. Damien explains, "I've received a tremendous amount of help over the years from others, especially early on, and I've made it my personal mission to help others as much as I can, both through my code contributions, user group support, mentoring, etc."

What does the Metatag Module do?

Editing metatag defaults

"Metatag is a system for controlling the hundreds of possible ‘meta’ tags that get added to HTML pages in order to provide more information about the page for search engines, social networks, and other services," explains Damien. "It also gives site builders and developers an API to define and add their own custom meta tags for situations where something completely tailor-made is needed, like for a custom tracking service. Metatag supports content editorial workflows, like Workbench Moderation, and has full multilingual and internationalization support, allowing the same page to load different meta tags depending upon the visitor's preferred browser language, for example."

As of early 2016, about 290,000 sites are using the Drupal 7 release. Just over a thousand are using the D8 version of Metatag.

Metatag configuration

Metatags on node creation form

Why is this important?

Metatag provides a standardized API and UX for developers to manage and control the meta tags for the sites they build. Rather than the meta tags being hardcoded into the site's template files--also making them impossible to change dynamically--it puts the power to control the tags in the hands of content creators on a per-page basis. Metatag Module includes a Drupal Console integration to make it easier for developers to add their own custom meta tags.

Metatag provides value to site owners by making it easier for potential visitors to find their site's content. Properly controlling a site's meta tags gives a business or organization more control over how their site's information is interpreted by search engines, and how the information is presented when pages are shared over social networks. For example, meta tags let you define which photo, description text, and other elements are shown, making social shares more appealing.

When was Metatag created?

"Metatag was started in 2011 as a ground-up rewrite of a Drupal 5 & 6 module, Nodewords. Dave Reid started the work and when he became too busy with other responsibilities I took over leading the effort. For what we hoped would become Drupal 7's defacto meta tag management module, we wanted something that was more flexible and more powerful than what was available on D6 and would provide a better out-of-the-box experience than had been possible with Nodewords."

Has Drupal 8 changed this module?

"With Drupal 8 we've taken advantage of the Field API for controlling the values that a site owner or content creator might wish to override on a per-entity (node, term, user, etc.) basis, rather than handling that using custom APIs." Outsourcing this functionality dramatically reduces the amount of code needed in the module and makes it more future-proof."

"A client Mediacurrent client, Manhattan Associates, sponsored the early work on the Drupal 8 port starting in early 2015. Since Drupal 8.0 was released Michelle Cox (who has been working on the module with Damien) and I have received a tremendous amount of help from others, adding more functionality and fixing bugs, so now it's getting pretty robust. One of the biggest additions was a new configuration system that juampynr from Lullabot wrote for us back in November 2015. That filled in a huge gap in the module's functionality and brought it much closer in line with what could be done on the D7 version. For the initial beta releases, we've been getting the architecture in place and ironing out the main bugs. As soon as that’s done, we'll begin piling on the almost 300 metatags available in the Drupal 7 version."

Sign-up for our Developer Blog Newsletter

Thanks!

Add comment

By submitting this form, you accept the Mollom privacy policy.

Getting rid of some meta tags

Hi, thanks for your article. My problem ist, i do not want to add metatags i want to delete some on all pages. For example i do not want to have the following meta tags on my page. Do you have any idea how to do that? Just to get rid of them.

<meta name="Generator" content="Drupal 8 (https://www.drupal.org)" />
<link rel="shortcut icon" href="/core/misc/favicon.ico" type="image/vnd.microsoft.icon" />
<link rel="canonical" href="/myfirstpage" />
<link rel="shortlink" href="/node/4" />
<link rel="delete-form" href="/node/4/delete" />
<link rel="edit-form" href="/node/4/edit" />
<link rel="version-history" href="/node/4/revisions" />
<link rel="revision" href="/myfirstpage" />