I could not find support for meta name="author" in the module, is this something that's missing or am I overlooking something? http://www.metatags.org/meta_name_author

Only could find the Google+ author page metatab but that is different.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pvhee’s picture

Issue summary: View changes
DamienMcKenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev

Oh my. Well fudge, the current tag's internal name is "author", so this would have to be e.g. "name_author". This would also then have to extend the API to allow an optional e.g. 'name_override' attribute in hook_metatag_info() that would replace the value in the HTML.

DamienMcKenna’s picture

Title: Support <meta name="author" metatag » Support name="author" meta tag
pvhee’s picture

As a temporary fast fix, I implemented the hook_metatag_info_alter hook to alter the author tag behavior. Of course this removes the author link, so it's probably not recommended to do this without understanding the impact of it, but it's definitely faster than patching metatag and the API

/**
 * Implements hook_metatag_info_alter().
 */
function mymodule_metatag_info_alter(&$info) {
  // Support normal author tag - see http://www.metatags.org/meta_name_author
  // We are effectively changing core Metatag behavior
  // @see https://www.drupal.org/node/2403349
  $info['tags']['author'] = array(
    'label' => t('Author'),
    'description' => t("Author of the website. See http://www.metatags.org/meta_name_author"),
    'class' => 'DrupalTextMetaTag',
    'context' => array('global'),
    'weight' => -10,
    // We need to add this again here, if not the tag name won't correctly show up.
    'name' => 'author'
  );
}

DamienMcKenna’s picture

Title: Support name="author" meta tag » Add new meta tag: name="author"

Standardized the issue title.

sitiveni’s picture

Adding the "Author" tag (or any other custom metatag) in Drupal 8 is done by creating files for schema and plugin.

Schema (my_module/config/schema/my_module.metatag_tag_schema.yml):

metatag.metatag_tag.author:
  type: label
  label: 'Author'

Plugin (my_module/src/Plugin/metatag/Tag/Author.php):

<?php

namespace Drupal\my_module\Plugin\metatag\Tag;

use Drupal\metatag\Plugin\metatag\Tag\MetaNameBase;

/**
 * The basic "Author" meta tag.
 *
 * @MetatagTag(
 *   id = "author",
 *   label = @Translation("Author"),
 *   description = @Translation("Define the author of a page."),
 *   name = "author",
 *   group = "basic",
 *   weight = 4,
 *   type = "label",
 *   secure = FALSE,
 *   multiple = FALSE
 * )
 */
class Author extends MetaNameBase {
  // Nothing here yet. Just a placeholder class for a plugin.
}
DamienMcKenna’s picture

DamienMcKenna’s picture

Title: Add new meta tag: name="author" » Add new meta tag: name="author" (D7)
DamienMcKenna’s picture

Need to do some more research on where this is actually used, and make sure there's a corresponding D8 issue too.

thejimbirch’s picture

Status: Active » Needs review

The author meta tag is a part of the HTML Living Standard specification:

https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-...

And in the W3C HTML 5.2 HTML 5.2 specification recommendation:

https://www.w3.org/TR/html52/document-metadata.html#author

Besides the page the original poster included, I can't find anyone that says they consume the author tag.

This article from Moz, originally from 2017, refreshed in 2019 states:

Nothing bad will happen to your site if you use these — let me just make that clear. They're a waste of space though; even Google says so (and that was 12 years ago now!)

The link to "Google saying so" is now broken.

I'd lean towards adding the tag and add the D8 issue to add the tag since it is in the official HTML specifications.

DamienMcKenna’s picture

Status: Needs review » Active
DamienMcKenna’s picture

Status: Active » Needs review
Parent issue: » #3102474: Plan for Metatag 7.x-1.27
FileSize
1.13 KB

Ok, well here's a first pass.

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 12: metatag-n2403349-12.patch, failed testing. View results

DamienMcKenna’s picture

Title: Add new meta tag: name="author" (D7) » Add new meta tag: name=author (D7)
DamienMcKenna’s picture

Status: Needs work » Needs review
FileSize
2.35 KB
3.47 KB

Ah! It fails because it conflict with the rel="author" meta tag from Google+. So let's just dump the G+ one and take over the namespace.

  • DamienMcKenna committed 3565fe4 on 7.x-1.x
    Issue #2403349 by DamienMcKenna, pvhee, thejimbirch: Convert "author"...
DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

DamienMcKenna’s picture

Title: Add new meta tag: name=author (D7) » Convert "author" tag to HTML 5.2 spec (D7)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.