Hi there!

I was migrating some of the old pages from Drupal 7 -> Drupal 8 and I noticed I couldn't save one of my migrated nodes due to:

Keywords cannot be longer than 255 characters but is currently 404 characters

Oddly migrate didn't have a problem assigning the full text to the field so am guessing there is a restriction via metatag at some level?

I took a look at the following issue:

#2706941: Translations of metatags are limited to 128 characters

and changed metatag.metatag_tag.schema to the following + cache rebuild but to no avail:

metatag.metatag_tag.keywords:
  type: text
  label: 'Keywords'

Was just curious if you might have any advice on how to best proceed. Thanks for any insight :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sylus created an issue. See original summary.

DamienMcKenna’s picture

I haven't tried any migrations of Metatag's data so can't provide any recommendations, sorry.

That said, do you really need 404 characters in a meta tag that's useless? (-:

dobe’s picture

Well. Metatags is limiting the field to 255 characters... What if your using tokens? 500 characters can easily translate to 100 (real) characters with tokens. I personally don't think there should be anything less then 1k characters in these fields.. Let the user decide what they want in them. Even if it is long. That is not our choice. Use description recommendations if you want to inform user.

DamienMcKenna’s picture

One work-around would be to add a regular text field that has the length you want, and set the defaults for the relevant content types to load that field.

dobe’s picture

The attached patch changes default field of meta tags to limit to 1024 chars instead of 255. I just tried setting up a bunch of token keywords and hit 750 characters that produced ~175 length.

dobe’s picture

@DamienMcKenna that is a work around. It doesn't fix "default" meta tag fields and it doesn't really give a good content editor experience.

dobe’s picture

Status: Active » Needs review
DamienMcKenna’s picture

If you set the "long" attribute of the "keywords" tag to TRUE for the Robots plugin, does it solve the problem?

DamienMcKenna’s picture

Status: Needs review » Needs work

I'd also suggest we instead document how to alter the annotations via hooks to change the plugin definition, "keywords" is such a useless meta tag today anyway.

dobe’s picture

I don't disagree about the keywords. But this patch affects descriptions tags as well unless I missed something? If you're using tokens to generate content within these tags. You're very limited. Hooks / annotations sound intriguing but just thinking that may be overkill for some people.

steveoriol’s picture

+1 for the patch: Due to the use of chain tokens which can be quite long in number of characters
ex:
Enseignant: [node:field_enseignant:0:entity:enseignant:field_adresse:given_name] [node:field_enseignant:0:entity:enseignant:field_adresse:family_name]
that give in final:
Enseignant: Xxxxxx XXXXX

bryanmws’s picture

+1 on this issue.

Having the same problem for Page Title Attribute. Token chaining is couple hundred characters long and client's not able to edit/translate texts.

DamienMcKenna’s picture

You really shouldn't be doing token chaining to that degree, you should set up separate configurations for each content type, vocabulary, etc as needed.

dobe’s picture

Can you explain setting up separate configurations? Is this documented? Because we are doing a different meta tags for each content type. Just so happens our content types have about 6-8 different taxonomies per content type... or product type.

When you chain those together in 1 or two orders blam there goes all your characters.

DamienMcKenna’s picture

Please check the README.txt file that's included in the module, the project page which has a link to a video with suggested setup, or the online documentation.

tyler-durden’s picture

I'm wondering if there has been any follow-up or further action on this issue? A 255 character limit when multiple tokens are in use is not enough characters, and it really doesn't seem like too much of a change according to this patch. Maybe the db field type needs to be changed also, but I just feel that a hard limit of 255 characters is severely limiting and not needed.

liquidcms’s picture

Also wondering if any progress here. Our government client, even though suggested to them that keywords are rarely used anywhere, has stated a requirement for over 1024 characters for keywords.

I am wondering why the simple fix here isn't to just make this a textarea field?

trobey’s picture

Status: Needs work » Needs review
FileSize
1.23 KB

The description field is limited to 320 characters and if the keywords length is increased then the description field should also be increased.

DamienMcKenna’s picture

Title: Keywords cannot be longer than 255 characters but is currently n characters » Expand all text fields to allow 1,024 characters

Thanks Tom, that change makes complete sense.

DamienMcKenna’s picture

Status: Needs review » Reviewed & tested by the community
Parent issue: » #3186720: Plan for Metatag 8.x-1.16

I'm going to commit this, just to give us some breathing room for sites that need it, we can pick up a longer term solution in #2958193: Automatically trim meta tag lengths (D9).

liquidcms’s picture

Great, thanks.

Havent looked through entire code; but this line in the patch sounds odd: '#type' => $this->isLong() ? 'textarea' : 'textfield',

why would this be dynamic? Just set as a textarea.

DamienMcKenna’s picture

Because most meta tags don't need to be textarea fields.

  • DamienMcKenna committed 8f6133b on 8.x-1.x authored by trobey
    Issue #2930291 by dobe, trobey, DamienMcKenna, sylus: Expand all text...
DamienMcKenna’s picture

Status: Reviewed & tested by the community » Fixed

Committed. Thank you.

Status: Fixed » Closed (fixed)

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