Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Configuring the Drupal 8 Metatag Module

Parent Feed: 

Meta tags are often underrated. Sure, they are not visible on your page up front but they are those hidden ninjas that can elevate your SEO game. These modest snippets of text that describe what your page is about can turn out to be very useful. The Drupal 8 Metatag module helps site builders to dynamically create and manage these meta tags for each of their web pages through an interactive admin interface (and no code!).

With the Drupal 8 Metatag module, you can not only provide structured metadata about a web page but can also customize meta tag elements. Meta elements are tags used in HTML or XHTML documents to provide structured metadata about a web page. They are part of a web page's head section. Multiple Meta elements with different attributes can be used on the same page. Lets learn more on improving SEO with the Metatag module. 

Setting-up the Drupal 8 Metatag Module

Meta elements can be used to specify page description, keywords and any other metadata not provided through the other head elements and attributes.You need to add  meta tags in the head section of your Drupal 8 pages for title, description, keywords, twitter card, facebook open-graph - to make your website SEO friendly. Download and install the module here.

With the Drupal Metatag module, we can configure the following -

  • Configuring Meta tags for home page(front page).
  • Configuring Meta tags for a Content type.
  • Configuring Meta tags for view pages.

1) Configuring Drupal 8 Meta tags for home page/front page.

After installing the module, you can edit global configurations at /admin/config/search/metatags and set the global configuration for the front page. Click on Edit to get into the details.

meta tag configuration                      Drupal 8 Metatag - Configuration for Front page

Enter Page title, Description, Abstract, and Keywords.

meta tag config module              Drupal 8 Metatag - Configuration for Front page

Page Title

This snippet is not only useful to search engines but also to your users. It appears in the title bar of your web page and should not exceed 55 characters. It also acts as a title for when your web page is bookmarked.


Description:

Enter a brief description of your website. Make sure that the description does not exceed 150 characters because search engines won't display more than that on a results page. If you don't have either field filled out, Google will decide what to display without any input from you. It can be very helpful to write up a snappy description for your content here.

Abstract

Enter a brief Abstract (Optional). Again, keep it to fewer than 150 characters but instead of something snappy, try to be as plainly descriptive as possible.

Keywords

Enter a comma separated list of keywords related to your website.

Advanced Settings and Custom Meta tags

There are some important things here that were previously handled by code. 

Drupal 8 Metatag - Advanced Settings             Drupal 8 Metatag - Advanced Settings

Robots

Normally, if you want to block or allow search engines from indexing a page or disallow search engines to display cached copies or descriptions of your page, you would edit the site-wide Robots.txt file. Here, you can control all of it and more with the Robots meta tag by checking/unchecking the various indexing options it provides.

News Keywords

This Meta tag is exclusively used by Google News that takes in comma-separated keywords as inputs. 

Rights

Any details about a copyright or trademarks that you might have, should go here.


Image

This one is also relatively new and can be handy for telling social networks which image they should use with a post.

Canonical URL

Canonical URLs are very useful for dealing with duplicate content issues. This is something that is often a problem on e-commerce sites where product listings are duplicated on multiple pages. Metatag does a good job of handling this by default.

Shortlink URL

This element acts as an alternative to link shorteners. In Drupal they usually come out looking something like this:

<link rel="shortlink" href="https://www.specbee.com/blogs/node/12" />

Original Source

This tag is also something that Google came up with, this time to help identify the original source of content. This one may be particularly useful for news sites, but can be safely ignored by most.
Save your settings.

2) Configuring Drupal 8 Meta tags for a Content type


Edit global configurations at  /admin/config/search/metatags, set the global configuration for Content. Click on Edit to get into the details. If you want to add different metatags for different content types, then click on the “Add default Meta tags” link on the top left corner of the page. Select the content type you wish to add metatag to and click on Save and configure.

Drupal Metatag - Configuration for Content types                    Drupal Metatag - Configuration for Content typesmeta tag ccongif for content type article      Drupal 8 Metatag - Configuration for Content type : Article

The content type will be listed in the Meta tags screen. The above screenshot shows the content type ‘Article’. Click on edit to add metatags.

Enter Page Title, Description, Abstract, and other necessary settings. Follow the same procedure as mentioned above in configuring metatags for the ‘front-page’.

3) Configuring Drupal 8 Meta tags for View pages


Enable “metatag: views” module which is a sub-module of the metatag module.

Drupal Metatag - Configuration for Views                  Drupal Metatag - Configuration for Views

Edit global configurations at /admin/config/search/metatags. Click on override to get into the details.
To add the meta tags in view go to the views edit screen and click on the meta tags link.

meta tag setting viewsmeta tag view

The above setting is the default setting for the view page.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web