backdrop-contrib / metatag

Add structured metadata, aka "meta tags", for various pages on your site.
GNU General Public License v2.0
3 stars 15 forks source link

Wrong meta description markup #56

Closed mazzech closed 3 years ago

mazzech commented 3 years ago

screen-meta-output

The current version seems to provide a false meta description text markup <meta property="description"> instead of <meta name="description">

This might affect every website using the module. There's a good workaround (using the meta seo module instead, but unfortunately without support for tokens). Thank you @indigoxela for confirmation of the bug

indigoxela commented 3 years ago

Another screenshot for comparison, I'm not using metatag module with any D7, but there's a D8 - and it sets the correct attribute (name, not property):

screenshot-meta-d8

Mozilla page for the meta tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta

Wikipedia page about RDFa - these do have property attributes: https://en.wikipedia.org/wiki/RDFa

BTW: the same is true for generator (wrong attribute "property" instead of "name")

indigoxela commented 3 years ago

And this is the commit that broke it: https://github.com/backdrop-contrib/metatag/commit/0ffd42573c21fae2dbbc9e3236263bc52515381f

This changed the attribute from hardcoded "name" to hardcoded "property", both doesn't seem right.

The D7 code looks pretty different: https://git.drupalcode.org/project/metatag/-/blob/7.x-1.x/metatag.inc#L164

And here's a quick and dirty workaround in metatag.inc (beginning with line 132):

        // Workaround, see backdrop-contrib/metatag/issues/56
        $has_name = array(
          'description',
          'generator',
        );
        $attribute = 'property';
        if (in_array($this->info['name'], $has_name)) {
          $attribute = 'name';
        }
        // Combine the base configuration for this meta tag with the value.
        $element = $base_element + array(
          '#tag' => 'meta',
          '#attributes' => array(
            $attribute => $this->info['name'],
            'content' => $value,
          ),
          '#weight' => $this->getWeight(),
        );

Note: it's no real solution. What it really needs is to switch back to the way D7 does it (with theme functions).

Note 2: twitter also wants the "name" attribute: https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started

neessen commented 3 years ago

This is a major issue with this module that makes it useless unless a solution can be found to this problem. All Backdrop sites using this module will not have their meta description indexed by Google until this is solved.

Building on the solution by @indigoxela I have made this workaround, but I think it is still a quick and dirty workaround:

if(in_array($this->info['group'], array("basic", "advanced"))){
  $meta_content_attribute = "name";
}else{
   $meta_content_attribute = "property";
}
 // Combine the base configuration for this meta tag with the value.
$element = $base_element + array(
  '#tag' => 'meta',
  '#attributes' => array(
    $meta_content_attribute => $this->info['name'],
    'content' => $value,
  ),
  '#weight' => $this->getWeight(),
);

The difference is, that i think all meta tags located in the basic and advanced tabs on the node edit page should be outputted with name instead of property: <meta name="resume".. <meta name="keywords".. <meta name="icbm" ... and so on. However the open graph tags (if used) shoud be outputted with property: <meta property="og:title".. <meta property="og:description".. and so on. Luckily these are categorized with their group name (basic, advanced, open_graph etc..) so this approach should output name= instead of property= for the basic and advanced group. However I would imagine that there would be better solutions than this, but with my limited skills in module development this was the solution I could think of, so any review, comments and suggestions would be appreciated :)

indigoxela commented 3 years ago

This is a major issue with this module

@neessen I agree.

Using the groups to distinguish the attributes is for sure worth a try. Do you happen to know in which group the twitter meta tags are? The twitter tags need "name".

Trying to ping @jenlampton (the current maintainer), as I suspect, she missed this new issue.

jenlampton commented 3 years ago

Thanks for the ping @indigoxela. I don't think the intent was for that commit to change all name attributes to properties, just some of them. I'm going to revert that and re-open the related issue.

neessen commented 3 years ago

Hey @indigoxela

Below is a list of all info on all possible fields at the moment. Looks like all the twitter stuff is placed in the "twitter-cards" group.

So I guess we could just add that to the group checkup array (see below)

@jenlampton thank you for looking into this :)
It is better to revert this (changing property to name), but we would still have issues with the tags that should be outputted with property then. (e.g open graph tags)

Updated code

if(in_array($this->info['group'], array("basic", "advanced", "twitter-cards"))){
  $meta_content_attribute = "name";
}else{
  $meta_content_attribute = "property";
}
// Combine the base configuration for this meta tag with the value.
$element = $base_element + array(
  '#tag' => 'meta',
  '#attributes' => array(
    $meta_content_attribute => $this->info['name'],
    'content' => $value,
  ),
  '#weight' => $this->getWeight(),
);

List of all tags:


Array
(
    [label] => Description
    [description] => A concise summary of the page's content, preferably 150 characters or less. May be used by in search results.
    [class] => BackdropTextMetaTag
    [group] => basic
    [weight] => 2
    [form] => Array
        (
            [#type] => textarea
            [#rows] => 2
            [#wysiwyg] => 
        )

    [name] => description
)
Array
(
    [label] => Abstract
    [description] => A oncise summary of the page's content, preferably 150 characters or less. May be used for archiving purposes.
    [class] => BackdropTextMetaTag
    [group] => basic
    [weight] => 3
    [form] => Array
        (
            [#type] => textarea
            [#rows] => 2
            [#wysiwyg] => 
        )

    [name] => abstract
)
Array
(
    [label] => Keywords
    [description] => A comma-separated list of keywords about the page. This meta tag is nolonger supported by most search engines.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 4
    [name] => keywords
)
Array
(
    [label] => Google News Keywords
    [description] => A comma-separated list of keywords about the page. This meta tag is used as an indicator in <a href="http://support.google.com/news/publisher/bin/answer.py?hl=en&amp;answer=68297">Google News</a>.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 5
    [name] => news_keywords
)
Array
(
    [label] => Google Standout
    [description] => Highlight standout journalism on the web, especially for breaking news; used as an indicator in <a href="https://support.google.com/news/publisher/answer/191283?hl=en&amp;ref_topic=2484650">Google News</a>. Warning: Don't abuse it, to be used a maximum of 7 times per calendar week!
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 6
    [name] => standout
)
Array
(
    [label] => Content rating
    [description] => Used to indicate the intended audience for the content.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [select_or_other] => 1
    [form] => Array
        (
            [#type] => select
            [#options] => Array
                (
                    [general] => General
                    [mature] => Mature
                    [restricted] => Restricted
                    [14 years] => 14 years or Older
                    [safe for kids] => Safe for kids
                )

            [#empty_option] => - None -
        )

    [weight] => 7
    [name] => rating
)
Array
(
    [label] => Referrer policy
    [description] => Indicate to search engines and other page scrapers whether or not links should be followed. See <a href="http://w3c.github.io/webappsec/specs/referrer-policy/">the W3C specifications</a> for further details.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [select_or_other] => 1
    [form] => Array
        (
            [#type] => select
            [#options] => Array
                (
                    [no-referrer] => No Referrer
                    [origin] => Origin
                    [no-referrer-when-downgrade] => No Referrer When Downgrade
                    [origin-when-cross-origin] => Origin When Cross-Origin
                    [unsafe-url] => Unsafe URL
                )

            [#empty_option] => - None -
        )

    [weight] => 8
    [name] => referrer
)
Array
(
    [label] => Rights
    [description] => Details about intellectual property, such as copyright or trademarks; does not automatically protect the site's content or intellectual property.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 10
    [replaces] => Array
        (
            [0] => copyright
        )

    [name] => rights
)
Array
(
    [label] => Original Source
    [description] => Used to indicate the URL that broke the story, and can link to either an internal URL or an external source. If the full URL is not known it is acceptable to use a partial URL or just the domain name.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 14
    [devel_generate] => Array
        (
            [type] => url
        )

    [name] => original-source
)
Array
(
    [label] => Content language
    [description] => Used to define this page's language code. May be the two letter language code, e.g. "de" for German, or the two letter code with a dash and the two letter ISO country code, e.g. "de-AT" for German in Austria. Still used by Bing.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 17
    [is_language] => 1
    [element] => Array
        (
            [#theme] => metatag_http_equiv
        )

    [name] => content-language
)
Array
(
    [label] => Geo position
    [description] => Geo-spatial information in "latitude;longitude" format, e.g. "50.167958;-97.133185"; <a href="http://en.wikipedia.org/wiki/Geotagging#HTML_pages">see Wikipedia for details</a>.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 18
    [name] => geo.position
)
Array
(
    [label] => Geo place name
    [description] => A location's formal name.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 19
    [name] => geo.placename
)
Array
(
    [label] => Geo region
    [description] => A location's two-letter international country code, with an optional two-letter region, e.g. "US-NH" for New Hampshire in the USA.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 20
    [name] => geo.region
)
Array
(
    [label] => ICBM
    [description] => Geo-spatial information in "latitude, longitude" format, e.g. "50.167958, -97.133185"; <a href="https://en.wikipedia.org/wiki/ICBM_address">see Wikipedia for details</a>.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 21
    [name] => icbm
)
Array
(
    [label] => Refresh
    [description] => The number of seconds to wait before refreshing the page. May also force redirect to another page using the format "5; url=http://example.com/", which would be triggered after five seconds.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 22
    [element] => Array
        (
            [#theme] => metatag_http_equiv
        )

    [name] => refresh
)
Array
(
    [label] => Revisit After
    [description] => Tell search engines when to index the page again. Very few search engines support this tag, it is more useful to use an <a href="https://backdropcms.org/project/xmlsitemap">XML Sitemap</a> file.
    [class] => BackdropDateIntervalMetaTag
    [group] => advanced
    [weight] => 23
    [devel_generate] => Array
        (
            [type] => date
        )

    [name] => revisit-after
)
Array
(
    [label] => Pragma
    [description] => Used to control whether a browser caches a specific page locally. Little used today. Should be used in conjunction with the Cache-Control meta tag.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 24
    [element] => Array
        (
            [#theme] => metatag_http_equiv
        )

    [name] => pragma
)
Array
(
    [label] => Cache-Control
    [description] => Used to control whether a browser caches a specific page locally. Little used today. Should be used in conjunction with the Pragma meta tag.
    [class] => BackdropTextMetaTag
    [group] => advanced
    [weight] => 25
    [element] => Array
        (
            [#theme] => metatag_http_equiv
        )

    [name] => cache-control
)
Array
(
    [label] => Expires
    [description] => Control when the browser's internal cache of the current page should expire. The date must to be an <a href="http://www.csgnetwork.com/timerfc1123calc.html">RFC-1123</a>-compliant date string that is represented in Greenwich Mean Time (GMT), e.g. 'Thu, 01 Sep 2016 00:12:56 GMT'. Set to '0' to stop the page being cached entirely.
    [class] => BackdropTextMetaTag
    [weight] => 26
    [group] => advanced
    [devel_generate] => Array
        (
            [type] => date
        )

    [name] => expires
)
Array
(
    [label] => Specific directions for robots:
    [class] => BackdropListMetaTag
    [group] => advanced
    [weight] => 27
    [form] => Array
        (
            [#options] => Array
                (
                    [noindex] => Prevent search engines from indexing this page.
                    [nofollow] => Prevent search engines from following links on this page.
                    [noarchive] => Prevent cached copies of this page from appearing in search results.
                    [nosnippet] => Prevent descriptions from appearing in search results, and prevents page caching.
                    [noodp] => Block the <a href="http://www.dmoz.org/">Open Directory Project</a> description from appearing in search results.
                    [noydir] => Prevent Yahoo! from listing this page in the <a href="http://dir.yahoo.com/">Yahoo! Directory</a>.
                    [noimageindex] => Prevent search engines from indexing images on this page.
                    [notranslate] => Prevent search engines from offering to translate this page in search results.
                    [index] => Allow search engines to index this page (assumed).
                    [follow] => Allow search engines to follow links on this page (assumed).
                )

        )

    [name] => robots
)
Array
(
    [label] => Admins
    [description] => A comma-separated list of Facebook user IDs of people who are considered administrators or moderators of this page.
    [weight] => 21
    [multiple] => 1
    [class] => BackdropTextMetaTag
    [group] => facebook
    [name] => fb:admins
)
Array
(
    [label] => Application ID
    [description] => A comma-separated list of Facebook Platform Application IDs applicable for this site.
    [weight] => 22
    [devel_generate] => Array
        (
            [type] => integer
        )

    [class] => BackdropTextMetaTag
    [group] => facebook
    [name] => fb:app_id
)
Array
(
    [label] => Pages
    [description] => Facebook Instant Articles claim URL token.
    [weight] => 23
    [devel_generate] => Array
        (
            [type] => integer
        )

    [class] => BackdropTextMetaTag
    [group] => facebook
    [name] => fb:pages
)
Array
(
    [label] => Content type
    [description] => The type of the content, e.g., <em>movie</em>.
    [weight] => 27
    [select_or_other] => 1
    [form] => Array
        (
            [#type] => select
            [#options] => Array
                (
                    [Activities] => Array
                        (
                            [activity] => Activity
                            [sport] => Sport
                        )

                    [Businesses] => Array
                        (
                            [bar] => Bar
                            [company] => Company
                            [cafe] => Cafe
                            [hotel] => Hotel
                            [restaurant] => Restaurant
                        )

                    [Groups] => Array
                        (
                            [cause] => Cause
                            [sports_league] => Sports league
                            [sports_team] => Sports team
                        )

                    [Organizations] => Array
                        (
                            [band] => Band
                            [government] => Government
                            [non_profit] => Non-profit
                            [school] => School
                            [university] => University
                        )

                    [People] => Array
                        (
                            [actor] => Actor
                            [athlete] => Athlete
                            [author] => Author
                            [director] => Director
                            [musician] => Musician
                            [politician] => Politician
                            [profile] => Profile
                            [public_figure] => Public figure
                        )

                    [Places] => Array
                        (
                            [city] => City
                            [country] => Country
                            [landmark] => Landmark
                            [place] => Place
                            [state_province] => State or province
                        )

                    [Products and Entertainment] => Array
                        (
                            [album] => Album
                            [book] => Book
                            [drink] => Drink
                            [food] => Food
                            [game] => Game
                            [product] => Product
                            [product.group] => Product group
                            [song] => Song
                            [video.movie] => Movie
                            [video.tv_show] => TV show
                            [video.episode] => TV show episode
                            [video.other] => Miscellaneous video
                        )

                    [Websites] => Array
                        (
                            [website] => Website
                            [article] => Article (inc blog)
                        )

                )

            [#empty_option] => - None -
        )

    [devel_generate] => Array
        (
            [type] => select
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:type
)
Array
(
    [label] => Page URL
    [description] => Preferred page location or URL to help eliminate duplicate content for search engines, e.g., <em>http://www.imdb.com/title/tt0117500/</em>.
    [weight] => 28
    [devel_generate] => Array
        (
            [type] => canonical
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:url
)
Array
(
    [label] => Content title
    [description] => The title of the content, e.g., <em>The Rock</em>.
    [weight] => 29
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:title
)
Array
(
    [label] => Content title determiner
    [description] => The word that appears before the content's title in a sentence. The default ignores this value, the 'Automatic' value should be sufficient if this is actually needed.
    [weight] => 30
    [form] => Array
        (
            [#type] => select
            [#options] => Array
                (
                    [auto] => Automatic
                    [a] => A
                    [an] => An
                    [the] => The
                )

            [#empty_option] => - Ignore -
        )

    [devel_generate] => Array
        (
            [type] => select
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:determiner
)
Array
(
    [label] => Content description
    [description] => A one to two sentence description of the content.
    [weight] => 31
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:description
)
Array
(
    [label] => Content modification date & time
    [description] => The date this content was last modified, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format. Can be the same as the 'Article modification date' tag.
    [weight] => 32
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:updated_time
)
Array
(
    [label] => See also
    [description] => URLs to related content.
    [multiple] => 1
    [weight] => 33
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:see_also
)
Array
(
    [label] => Image
    [description] => The URL of an image which should represent the content. For best results use an image that is at least 1200 x 630 pixels in size, but at least 600 x 316 pixels is a recommended minimum. Supports PNG, JPEG and GIF formats. Should not be used if og:image:url is used. Note: if multiple images are added many services (e.g. Facebook) will default to the largest image, not the first one.
    [multiple] => 1
    [image] => 1
    [weight] => 34
    [devel_generate] => Array
        (
            [type] => image
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:image
)
Array
(
    [label] => Image URL
    [description] => A alternative version of og:image and has exactly the same requirements; only one needs to be used. Note: some services do not accept this tag and will only accept the "image" tag above.
    [multiple] => 1
    [image] => 1
    [weight] => 35
    [devel_generate] => Array
        (
            [type] => image
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:image:url
)
Array
(
    [label] => Secure image URL
    [description] => The secure URL (HTTPS) of an image which should represent the content. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. Supports PNG, JPEG and GIF formats. All "http://" URLs will automatically be converted to "https://". Note: if multiple images are added many services (e.g. Facebook) will default to the largest image, not the first one.
    [multiple] => 1
    [secure] => 1
    [image] => 1
    [weight] => 36
    [devel_generate] => Array
        (
            [type] => image
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:image:secure_url
)
Array
(
    [label] => Image type
    [description] => The type of image referenced above. Should be either "image/gif" for a GIF image, "image/jpeg" for a JPG/JPEG image, or "image/png" for a PNG image. Note: there should be one value for each image, and having more than there are images may cause problems.
    [multiple] => 1
    [weight] => 37
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:image:type
)
Array
(
    [label] => Image width
    [description] => The width of the above image(s). Note: if both the unsecured and secured images are provided, they should both be the same size.
    [multiple] => 1
    [weight] => 38
    [devel_generate] => Array
        (
            [type] => image
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:image:width
)
Array
(
    [label] => Image height
    [description] => The height of the above image(s). Note: if both the unsecured and secured images are provided, they should both be the same size.
    [multiple] => 1
    [weight] => 39
    [devel_generate] => Array
        (
            [type] => image
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:image:height
)
Array
(
    [label] => Latitude
    [weight] => 40
    [devel_generate] => Array
        (
            [type] => float
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:latitude
)
Array
(
    [label] => Longitude
    [weight] => 41
    [devel_generate] => Array
        (
            [type] => float
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:longitude
)
Array
(
    [label] => Street address
    [weight] => 42
    [replaces] => Array
        (
            [0] => og:street-address
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:street_address
)
Array
(
    [label] => Locality
    [weight] => 43
    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:locality
)
Array
(
    [label] => Region
    [weight] => 44
    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:region
)
Array
(
    [label] => Postal/ZIP code
    [weight] => 45
    [replaces] => Array
        (
            [0] => og:postal-code
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:postal_code
)
Array
(
    [label] => Country name
    [weight] => 46
    [replaces] => Array
        (
            [0] => og:country-name
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:country_name
)
Array
(
    [label] => Email
    [weight] => 47
    [devel_generate] => Array
        (
            [type] => email
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:email
)
Array
(
    [label] => Phone number
    [weight] => 48
    [devel_generate] => Array
        (
            [type] => phone
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:phone_number
)
Array
(
    [label] => Fax number
    [weight] => 49
    [devel_generate] => Array
        (
            [type] => phone
        )

    [description] => 
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:fax_number
)
Array
(
    [label] => Locale
    [description] => The locale these tags are marked up in, must be in the format language_TERRITORY. Default is en_US.
    [weight] => 50
    [is_language] => 1
    [devel_generate] => Array
        (
            [maxlength] => 1
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:locale
)
Array
(
    [label] => Alternative locales
    [description] => Other locales this content is available in, must be in the format language_TERRITORY, e.g. "fr_FR".
    [weight] => 51
    [multiple] => 1
    [is_language] => 1
    [devel_generate] => Array
        (
            [maxlength] => 1
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:locale:alternate
)
Array
(
    [label] => Audio URL
    [description] => The URL to an audio file that complements this object.
    [weight] => 63
    [devel_generate] => Array
        (
            [type] => url
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:audio
)
Array
(
    [label] => Audio secure URL
    [description] => The secure URL to an audio file that complements this object. All "http://" URLs will automatically be converted to "https://".
    [secure] => 1
    [weight] => 64
    [devel_generate] => Array
        (
            [type] => url
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:audio:secure_url
)
Array
(
    [label] => Audio type
    [description] => The MIME type of the audio file. Examples include "application/mp3" for an MP3 file.
    [weight] => 65
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:audio:type
)
Array
(
    [label] => Video URL
    [description] => The URL to a video file that complements this object.
    [weight] => 70
    [replaces] => Array
        (
            [0] => og:video
        )

    [devel_generate] => Array
        (
            [type] => url
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:video:url
)
Array
(
    [label] => Video secure URL
    [description] => A URL to a video file that complements this object using the HTTPS protocol. All "http://" URLs will automatically be converted to "https://".
    [secure] => 1
    [weight] => 71
    [devel_generate] => Array
        (
            [type] => url
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:video:secure_url
)
Array
(
    [label] => Video width
    [description] => The width of the video.
    [weight] => 72
    [devel_generate] => Array
        (
            [type] => integer
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:video:width
)
Array
(
    [label] => Video height
    [description] => The height of the video.
    [weight] => 73
    [devel_generate] => Array
        (
            [type] => integer
        )

    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:video:height
)
Array
(
    [label] => Video type
    [description] => The MIME type of the video file. Examples include "application/x-shockwave-flash" for a Flash video, or "text/html" if this is a standalone web page containing a video.
    [weight] => 74
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:video:type
)
Array
(
    [label] => Actor(s)
    [description] => Links to the Facebook profiles for actor(s) that appear in the video.
    [multiple] => 1
    [weight] => 75
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => video:actor
)
Array
(
    [label] => Actors' role
    [description] => The roles of the actor(s).
    [multiple] => 1
    [weight] => 76
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => video:actor:role
)
Array
(
    [label] => Director(s)
    [description] => Links to the Facebook profiles for director(s) that worked on the video.
    [weight] => 77
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => video:director
)
Array
(
    [label] => Scriptwriter(s)
    [description] => Links to the Facebook profiles for scriptwriter(s) for the video.
    [multiple] => 1
    [weight] => 78
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => video:writer
)
Array
(
    [label] => Video duration (seconds)
    [description] => The length of the video in seconds
    [weight] => 79
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => video:duration
)
Array
(
    [label] => Release date
    [description] => The date the video was released.
    [weight] => 80
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => video:release_date
)
Array
(
    [label] => Tag
    [description] => Tag words associated with this video.
    [multiple] => 1
    [weight] => 81
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => video:tag
)
Array
(
    [label] => Twitter card type
    [description] => Notes: no other fields are required for a <em>Summary</em> card, a <em>Photo</em> card requires the 'image' field, a <em>Media player</em> card requires the 'title', 'description', 'media player URL', 'media player width', 'media player height' and 'image' fields, a <em>Summary Card with Large Image</em> card requires the 'Summary' field and the 'image' field, a <em>Gallery Card</em> requires all the 'Gallery Image' fields, an <em>App Card</em> requires the 'iPhone app ID' field, the 'iPad app ID' field and the 'Google Play app ID' field, a <em>Product Card</em> requires the 'description' field, the 'image' field, the 'Label 1' field, the 'Data 1' field, the 'Label 2' field and the 'Data 2' field.
    [weight] => 41
    [form] => Array
        (
            [#type] => select
            [#options] => Array
                (
                    [summary] => Summary (default)
                    [summary_large_image] => Summary with large image
                    [photo] => Photo
                    [player] => Media player
                    [gallery] => Gallery
                    [app] => App
                    [product] => Product
                )

            [#empty_option] => - None -
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:card
)
Array
(
    [label] => Creator's Twitter account
    [description] => The @username for the content creator / author for this page, including the @ symbol.
    [weight] => 44
    [devel_generate] => Array
        (
            [type] => twitter
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:creator
)
Array
(
    [label] => Creator's Twitter account ID
    [description] => The numerical Twitter account ID for the content creator / author for this page.
    [weight] => 45
    [devel_generate] => Array
        (
            [type] => integer
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:creator:id
)
Array
(
    [label] => Page URL
    [description] => The permalink / canonical URL of the current page.
    [weight] => 46
    [devel_generate] => Array
        (
            [type] => canonical
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:url
)
Array
(
    [label] => Title
    [description] => The page's title, which should be concise; it will be truncated at 70 characters by Twitter. This field is required unless this the 'type' field is set to "photo".
    [weight] => 47
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:title
)
Array
(
    [label] => Description
    [description] => A description that concisely summarizes the content of the page, as appropriate for presentation within a Tweet. Do not re-use the title text as the description, or use this field to describe the general services provided by the website. The string will be truncated, by Twitter, at the word to 200 characters.
    [weight] => 48
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:description
)
Array
(
    [label] => Image URL
    [description] => The URL to a unique image representing the content of the page. Do not use a generic image such as your website logo, author photo, or other image that spans multiple pages. Images larger than 120x120px will be resized and cropped square based on longest dimension. Images smaller than 60x60px will not be shown. If the 'type' is set to <em>Photo</em> then the image must be at least 280x150px.
    [image] => 1
    [weight] => 49
    [replaces] => Array
        (
            [0] => twitter:image:src
        )

    [devel_generate] => Array
        (
            [type] => image
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:image
)
Array
(
    [label] => Image width
    [description] => The width of the image being linked to, in pixels.
    [weight] => 50
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => twitter:image
                    [attribute] => value
                    [condition] => filled
                    [value] => 1
                )

        )

    [devel_generate] => Array
        (
            [type] => integer
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:image:width
)
Array
(
    [label] => Image height
    [description] => The height of the image being linked to, in pixels.
    [weight] => 51
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => twitter:image
                    [attribute] => value
                    [condition] => filled
                    [value] => 1
                )

        )

    [devel_generate] => Array
        (
            [type] => integer
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:image:height
)
Array
(
    [label] => Image alternative text
    [description] => The alternative text of the image being linked to. Limited to 420 characters.
    [weight] => 52
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => twitter:image
                    [attribute] => value
                    [condition] => filled
                    [value] => 1
                )

        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:image:alt
)
Array
(
    [label] => App Store Country
    [description] => If your application is not available in the US App Store, you must set this value to the two-letter country code for the App Store that contains your application.
    [weight] => 62
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:country
)
Array
(
    [label] => iPhone app name
    [description] => The name of the iPhone app.
    [weight] => 63
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:name:iphone
)
Array
(
    [label] => iPhone app ID
    [description] => String value, should be the numeric representation of your iPhone app's ID in the App Store.
    [weight] => 64
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:id:iphone
)
Array
(
    [label] => iPhone app's custom URL scheme
    [description] => The iPhone app's custom URL scheme (must include "://" after the scheme name).
    [weight] => 65
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:url:iphone
)
Array
(
    [label] => iPad app name
    [description] => The name of the iPad app.
    [weight] => 66
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:name:ipad
)
Array
(
    [label] => iPad app ID
    [description] => String value, should be the numeric representation of your iPad app's ID in the App Store.
    [weight] => 67
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:id:ipad
)
Array
(
    [label] => iPad app's custom URL scheme
    [description] => The iPad app's custom URL scheme (must include "://" after the scheme name).
    [weight] => 68
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:url:ipad
)
Array
(
    [label] => Google Play app name
    [description] => The name of the app in the Google Play app store.
    [weight] => 69
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:name:googleplay
)
Array
(
    [label] => Google Play app ID
    [description] => Your app ID in the Google Play Store (i.e. "com.android.app").
    [weight] => 70
    [element] => Array
        (
            [#theme] => metatag_twitter_cards
        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:id:googleplay
)
Array
(
    [label] => Google Play app's custom URL scheme
    [description] => The Google Play app's custom URL scheme (must include "://" after the scheme name).
    [weight] => 71
    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:app:url:googleplay
)
Array
(
    [label] => Label 1
    [description] => This field expects a string, and you can specify values for labels such as price, items in stock, sizes, etc.
    [weight] => 72
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => twitter:card
                    [attribute] => value
                    [condition] => value
                    [value] => product
                )

        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:label1
)
Array
(
    [label] => Data 1
    [description] => This field expects a string, and allows you to specify the types of data you want to offer (price, country, etc.).
    [weight] => 73
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => twitter:card
                    [attribute] => value
                    [condition] => value
                    [value] => product
                )

        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:data1
)
Array
(
    [label] => Label 2
    [description] => This field expects a string, and you can specify values for labels such as price, items in stock, sizes, etc.
    [weight] => 74
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => twitter:card
                    [attribute] => value
                    [condition] => value
                    [value] => product
                )

        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:label2
)
Array
(
    [label] => Data 2
    [description] => This field expects a string, and allows you to specify the types of data you want to offer (price, country, etc.).
    [weight] => 75
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => twitter:card
                    [attribute] => value
                    [condition] => value
                    [value] => product
                )

        )

    [class] => BackdropTextMetaTag
    [group] => twitter-cards
    [name] => twitter:data2
)
Array
(
    [label] => Article modification date & time
    [description] => The date this content was last modified, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format.
    [weight] => 57
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => og:type
                    [attribute] => value
                    [condition] => value
                    [value] => article
                )

        )

    [name] => article:modified_time
)
Array
(
    [label] => Article publication date & time
    [description] => The date this content was published on, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format.
    [weight] => 56
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [dependencies] => Array
        (
            [0] => Array
                (
                    [dependency] => og:type
                    [attribute] => value
                    [condition] => value
                    [value] => article
                )

        )

    [name] => article:published_time
)
Array
(
    [label] => Generator
    [description] => Describes the name and version number of the software or publishing tool used to create the page.
    [class] => BackdropTextMetaTag
    [header] => X-Generator
    [context] => Array
        (
            [0] => global
        )

    [group] => advanced
    [weight] => 9
    [name] => generator
)
Array
(
    [label] => Site name
    [description] => A human-readable name for the site, e.g., <em>IMDb</em>.
    [context] => Array
        (
            [0] => global
        )

    [weight] => 26
    [class] => BackdropTextMetaTag
    [group] => open-graph
    [name] => og:site_name
)
indigoxela commented 3 years ago

@neessen many thanks for providing all the info.

I get the impression that only two groups need the property attribute:

The rest needs name. If we can agree on that, a fix should be fairly easy.

@jenlampton I suppose you prefer to continue on that other (now re-opened) issue?

indigoxela commented 3 years ago

Anyway, here's a PR that adopts @neessen's suggestion to use the group info to distinguish the attribute.

Besides the hardcoded attribute problem, this PR also fixes some (but not all) functional tests. They didn't break because of this PR, but must have been broken for quite a while. (Tested with php 7.4)

At least, the relevant tests for this issue here are passing.

@jenlampton I'll open a new issue for the two (unrelated) failing tests.

indigoxela commented 3 years ago

Another update for the PR fixes the caching test - it was just an oversight in var_export(), everything seems to work fine.

How to test:

If you're not planning to check the functional tests (Simpletest), it's sufficient to download the first commit patch to the main directory of your Metatag install.

Then apply the change (via command line) with: patch -p1 < c018c025bf8728b4575bbfd564f12cc562c2c5ea.patch and flush caches.

The attributes of all the meta tags added by this module should be correct then. For instance "name" for "description" and "property" for "og:image". Feedback is welcome.

Here's a screenshot of markup of a site this patch has been applied: screenshot-metatags

indigoxela commented 3 years ago

Any progress? Reminder: there's a PR available, which needs testing and review. It fixes a major bug.

I wonder if the @backdrop-contrib/bug-squad team could help here?

jenlampton commented 3 years ago

Bug squad can help if the issue is rtbc for 2 weeks or more.

On Wed, Nov 4, 2020, 11:29 PM indigoxela notifications@github.com wrote:

Any progress? Reminder: there's a PR available, which needs testing and review. It fixes a major bug.

I wonder if the @backdrop-contrib/bug-squad https://github.com/orgs/backdrop-contrib/teams/bug-squad team could help here?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/backdrop-contrib/metatag/issues/56#issuecomment-722197019, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADBERZH7QRMS72X4SW7R6TSOJH47ANCNFSM4SHIUVHQ .

jenlampton commented 3 years ago

@indigoxela the PR looks good. Testing the group isn't ideal, but it fixes the issue so I've merged the PR. :)