I have a paragraph field (named "content") as my main content field, so I'm trying to use this field to populate the "description" meta tag (with the metatag and token modules). The token used for this is simply [node:field_content:0].

One thing I noticed: on my front page, the first paragraph is composed of three fields (one long text, two simple text). The resulting output in the description meta tag is as follows:

[content of the long text field]
[one line containing only six spaces]
[10 empty lines]
[12 spaces][content of the first simple text field]
[one line containing only six spaces]
[10 empty lines]
[12 spaces][content of the second simple text field]

On the content type configuration (manage display), I activated the "token" display mode. In it, the paragraph is set to "Rendered as Token".
On the paragraph configuration, I also activated the "token" display mode.

Since I also use display suite, I set the "Current layout" for this display mode to "full reset", and the field template for each field to "reset" (both on the content type and on the paragraph). That made things marginally better, removing most of the useless space characters. But the 10 empty lines between each fields remain (and also two spaces before each fields except the first one).

On more complex paragraph types (I have a case with 3 levels of nesting: a paragraph within a paragraph within a paragraph), the resulting output contains 28 empty lines between two sentences.

Since those empty lines appear in the middle of the description (not at the beginning or end, where they could easily be trimmed), I don't know how Google or other search engines will treat them... For now, I just configured my various paragraph types to only output one field (the most relevant) in the token display mode, since those empty lines don't appear when there's only one field.

Comments

s427 created an issue. See original summary.

Berdir’s picture

Status: Active » Closed (works as designed)

That's because the token will actually return a ton of HTML around those field values which are stripped by metatags. Either use more specific tokens (e.g. node:field_paragraphs:0:field_text:value] to just get a raw value, but that wouldn't work with different/multiple paragraph types but I don't quite understand why you'd want multiple paragraph types in there.. in our projects, we always use a separate simple text field for teasers and metatags.

The only module that could drop those empty lines would be metatags.