Metatag

by Gisle Hannemyr

The Metatag module .

Table of contents

Drupal modules discussed in this chapter: Metatag, Token.

Introduction

The Metatag module allows you to automatically provide structured metadata (“meta tags”) about a website. The primary use of meta tags is SEO. This module also provides support for the Facebook Open Graph Protocol and Twitter Cards to give some control of how content appears when shared on social media.

The module uses “tokens” to automatically fill in values for different meta tags. Specific values may also be filled in.


Epost: Titan-twitter-hjelp (2019-07-02)

Vi har en dårlig presentasjon av sakene våre på Twitter. Jeg trodde det kunne løses i Twitter, men har skjønt at det må gjøres i Drupal. Lite kompetanse der og angst for å gjøre noe galt gjør at jeg sender utfordringen videre til deg.

Dette handler om å lage "cards", det vil si at twittermeldingen med bilde kommer opp som noe man kan klikke rett inn på, ikke bare som en synlig url som man deretter må legge et statisk bilde på. Se annertech.com[1]. Drupal har også sider om dette, ser jeg.

Under er litt info med skjermdumper fra nettredaksjonen sentralt.

Fra nettredaksjonen sentralt:

Jeg har noen tips - men understreker at disse gjelder for Vortex, så usikker på akkurat hvordan det er for Titan, men tipper at prinsippene er de samme.

For det første må det ligge en metabeskrivelse inne - som dermed gir deg en forklarende ingress - og ikke bare en generisk. Se vedlagte skjermdump - i Vortex er dette under fanen "om".

Så må det ligge et bilde som er stort nok i saken, til at det også blir stort på Twitter og dermed mer synlig i feeden. Du kan se forhåndsvisning av tweeten vha card validator[4], hvor du skriver inn url - og i Card URL-feltet skriver inn url-en til saken du skal dele (se vedlagte skjermdump).

Lenker:

  1. annertech.com (Drupal 7 - 2014)
  2. hostadvice.com (Drupal 8 - 2018)
  3. webwash.net (Drupal 7 - 2013)
  4. Validator

Installing and enabling the module

Use this command in the composer project directory:

$ composer require 'drupal/metatag:^1.12'

This will download the following projects:

Enable the following modules:

Needed?

The best way of using Metatag is as follows:

  1. Customize the global defaults, fill in the specific values and tokens that every page should have.
  2. Override each of the other defaults, fill in specific values and tokens that each item should have by default. This allows e.g. for all nodes to have different values than taxonomy terms.
  3. Add more default configurations as necessary for different entity types and entity bundles, e.g. for different content types or different vocabularies.
  4. To override the meta tags for individual entities, e.g. for individual nodes, add the “Metatag” field via the field settings for that entity or bundle type.

To customize the global defaults (i.e.the specific values and tokens that every page should have), navigate to Configuration » Search and metadata » Metatag » Metatag defaults. Locate the “Global” type and click on the “Edit” button on the right. However, the presets for the global defaults are OK, and it is not necessary to change them.

To see what tokens are available, click “Browse available tokens”. It produces a popup.

The settings for Twitter cards are locted near the bottom.

[current-page:title] | [site:name]

Metatag permissions

Metatag configuration

The Metatag project has its own configuration menu. It appears in the black band of the standard Drupal administrative toolbar.

Final word

[TBA]


Last update: 2020-04-21 for D7 [gh].