Bug #86956
openTyposcript meta tag field settings have no effect
Added by Christoph Sölder about 6 years ago. Updated almost 4 years ago.
0%
Description
When defining meta tags with typoscript for example
page {
meta {
author = {$page.meta.author}
author {
override.field = author
}
}
}
the override value is not rendered in the frontend if it is set in the backend.
The frontend alway shows the value set in {$page.meta.author}.
Similar if you define a meta tag that takes it's value directly from a database field e.g.
page {
meta {
author.field = author
}
}
The tag is not rendered in the frontend.
Using `page.meta.author.replace=1` doesn't help either.
The only way i got the override to work is the following:
page.meta.author.override.field >
page.meta.author.override.data = DB:pages:{TSFE:id}:author
page.meta.author.override.data.insertData = 1
To me it seems like the parameter "field" isn't working as expected.
Updated by Richard Haeser about 6 years ago
- Status changed from New to Accepted
I can confirm this issue
Updated by Vasyl Mosiychuk almost 6 years ago
I can confirm this issue too...
My TYPO3 9.5.1, PHP 7.2
page {
meta {
author = {$page.meta.author}
author {
override.field = author
}
keywords = {$page.meta.keywords}
keywords {
override.field = keywords
}
}
}
...and it is not working
page {
meta {
author.data = author
keywords.data = keywords
}
}
page {
meta {
author.data = levelfield:-1, author, slide
keywords.data = levelfield:-1, keywords, slide
}
}
...very strange but it is working
page {
meta {
description = {$page.meta.description}
description {
override.field = description
}
}
}
...and it is working
page {
meta {
keywords.data = page:keywords
author.data = page:author
}
}
Updated by Vasyl Mosiychuk almost 6 years ago
Tested on the TYPO3 v. 9.5.1 with Bootstrap Package 10.0.4 - working
page {
meta {
keywords = {$page.meta.keywords}
keywords {
stdWrap {
override {
data = page:keywords
}
}
}
author = {$page.meta.author}
author {
stdWrap {
override {
data = page:author
}
}
}
}
}
Updated by Riccardo De Contardi almost 6 years ago
These are my findings with TYPO3 9.5.2 (latest master)
- I created three constants
- on one page, I set the values of the fields author, keyword, description
These three lines are always present on each test¶
page.meta.author = {$page.meta.author}
>>> constant is shownpage.meta.keywords = {$page.meta.keywords}
>>> constant is shownpage.meta.description = {$page.meta.description}
>>> Note: in this situation the description field of the page properties will be taken; if not empty!
For each test, I added the following three lines (each time a different set of lines)
Test 1 - added:¶
page.meta.author.override.field = author
>>> Does not work; the constant is shownpage.meta.keywords.override.field = keywords
>>> Does not work; the constant is shownpage.meta.description.override.field = description
>>>Works the field value is taken; but see the previous Note!
Test 2 - added:¶
@page.meta.author.data = author >>> Does not work; the tag is missing
@page.meta.keywords.data = keywords >>> Does not work; the tag is missing
@page.meta.description.data = description >>> Works, but see the previous Note!
Test 4 - added:¶
page.meta.author.data = page:author
>>> Works the field value is taken; the tag is missing if empty page.meta.keywords.data = page:keywords
>>> Works the field value is taken; the tag is missing if empty page.meta.description.data = page:description
>>> Works the field value is taken; the tag is missing if empty
Test 5 - added:¶
page.meta.author.data = levelfield:-1, author, slide
>>> Works the field value is taken; also the slide workspage.meta.keywords.data = levelfield:-1, keywords, slide
>>> Works the field value is taken; also the slide works page.meta.description.data = levelfield:-1, description, slide
>>> Works the field value is taken; also the slide works
NOTE 2: in Install Tool, set ['FE']['addRootLineFields'] => 'author,description,keywords'
Test 6 - added:¶
page.meta.author.override.data = page:author
>>> Works the field value is taken; constant is shown if emptypage.meta.keywords.override.data = page:keywords
>>> Works the field value is taken; constant is shown if emptypage.meta.description.override.data = page:description
>>> Works the field value is taken; constant is shown if empty
Test 7 - added:¶
page.meta.author.stdWrap.override.data = page:author
>>> Works the field value is taken; constant is shown if emptypage.meta.keywords.stdWrap.override.data = page:keywords
>>> Works the field value is taken; constant is shown if emptypage.meta.description.stdWrap.override.data = page:description
>>> Works the field value is taken; constant is shown if empty
Updated by Richard Haeser almost 6 years ago
- Status changed from Accepted to Needs Feedback
Can you check again? Can't reproduce anymore. (Also not on 9.5.1...)
Updated by Riccardo De Contardi almost 6 years ago
@Richard Haeser I repeated the same tests with 9.5.4 and had slightly different results:
Test 1 -> same results
Test 2 -> one different result:page.meta.description.data = description
>>> Value from field is taken if not empty; Tag is missing if empty
Test 4 -> same results
Test 5 -> all different results:page.meta.author.data = levelfield:-1, author, slide
>>> Does not work; the tag is missing; also the slide workspage.meta.keywords.data = levelfield:-1, keywords, slide
>>> Does not work; the tag is missing; also the slide works page.meta.description.data = levelfield:-1, description, slide
>>> Value from field is taken if not empty; Tag is missing if empty; also the slide works
Test 6 -> same results
Test 7 -> same results
I cleared the frontend cache before each test.
Updated by Benjamin Eyring over 5 years ago
This issue still seems active in 9.5.5
As a workaround we solved it like this:
1. Deactivate rendering of the seo tags:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Frontend\Page\PageGenerator']['generateMetaTags'] = NULL;
2. Set the fields to slide=true:
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] = 'og_title,og_description,og_image,twitter_title,twitter_description,twitter_image,author,author_email';
3. Manually manage seo tags using TS:
70 = COA
70 {
# OG:TITLE ###########################################
10 = TEXT
10 {
data = levelfield:-1, og_title, slide
noTrimWrap = |<meta property="og:title" content="|" />|
}
# OG:TYPE ###########################################
20 = TEXT
20 {
value = website
noTrimWrap = |<meta property="og:type" content="|" />|
}
# OG:URL #############################################
30 = TEXT
30 {
typolink {
parameter.data = tsfe:id
parameter.insertData = 1
useCacheHash = 1
addQueryString = 1
addQueryString.method = get
addQueryString.exclude = id
forceAbsoluteUrl = 1
returnLast = url
}
wrap = <meta property="og:url" content="|">
}
# OG:DESCRIPTION ######################################
40 = TEXT
40 {
data = levelfield:-1, og_description, slide
stdWrap.wrap = <meta property="og:description" content="|" />
}
# OG:IMAGE ############################################
# Adaption for news see below
50 = FILES
50 {
references {
data = levelfield:-1, og_image, slide
}
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:publicUrl
}
stdWrap.dataWrap = <meta property="og:image" content="{site:base}|" />
required = 1
}
}
TBD: Check, if these tags are set correctly for news detail pages.
Don't know if there is a better solution?
Updated by Riccardo De Contardi over 5 years ago
I repeated my tests (see comment 4) on 9.5.8 with a more rich scenario:
- I created three constants:
page.meta.author = AUTORE DA COSTANTE page.meta.keywords = KEYWORD DA COSTANTE page.meta.description = DESCRIPTION DA COSTANTE
- I created four pages
Page A
Author field: filled with AUTORE DA PAGINA
Keyword field: filled with KEYWORD DA PAGINA
Description field: filled with DESCRIPTION DA PAGINA
Page B
Author field: empty
Keyword field: empty
Description field: filled with DESCRIPTION DA PAGINA
Page C
Author field: filled with AUTORE DA PAGINA
Keyword field: filled with KEYWORD DA PAGINA
Description field: empty
Page D
Author field: empty
Keyword field: empty
Description field: empty
So to sum up
Page A | Page B | Page C | Page D | |
---|---|---|---|---|
Author | filled | [empty] | filled | [empty] |
Kewyord | filled | [empty] | filled | [empty] |
Description | filled | filled | [empty] | [empty] |
Note: for test 5 that involves the "slide" I created a subpage for each page; the fields on all the subpages are always empty;
on Install Tool I set ['FE']['addRootLineFields'] => 'author,description,keywords'
- for each test, the lines:
page.meta.author = {$page.meta.author} page.meta.keywords = {$page.meta.keywords} page.meta.description = {$page.meta.description}
are always present
- before each test, I cleared the cache
I sum up in the following table the results of all the tests;
legend:
for each cell of the table, I report the values taken for Author, Keywords and Description in this order;
"C" means that the value from the constants is taken; "P" means that the value from the page field is taken; "/" means that the tag is absent
Test | Page A | Page B | Page C | Page D |
---|---|---|---|---|
only page.meta.author = {$page.meta.author} page.meta.keywords = {$page.meta.keywords} page.meta.description = {$page.meta.description} |
C C P | C C P | C C C | C C C |
Added:page.meta.author.override.field = author page.meta.keywords.override.field = keywords page.meta.description.override.field = description |
P P P | C C P | P P C | C C C |
Added:page.meta.author.data = author page.meta.keywords.data = keywords page.meta.description.data = description |
/ / P | / / P | / / / | / / / |
Added:page.meta.author.data = page:author page.meta.keywords.data = page:keywords page.meta.description.data = page:description |
P P P | / / P | P P / | / / / |
Added:page.meta.author.data = levelfield:-1, author, slide page.meta.keywords.data = levelfield:-1, keywords, slide page.meta.description.data = levelfield:-1, description, slide |
P P P | / / P | P P / | / / / |
same configuration of the previous line; checked the subpage of each page | P P P | / / P | P P / | / / / |
Added:page.meta.author.override.data = page:author page.meta.keywords.override.data = page:keywords page.meta.description.override.data = page:description |
P P P | C C P | P P C | C C C |
Added:page.meta.author.stdWrap.override.data = page:author page.meta.keywords.stdWrap.override.data = page:keywords page.meta.description.stdWrap.override.data = page:description |
P P P | C C P | P P C | C C C |
From a first glance, the test with
page.meta.author.data = author page.meta.keywords.data = keywords page.meta.description.data = description
seems to present the most faulty behavior;
Updated by Richard Haeser almost 5 years ago
- Status changed from Needs Feedback to New
Updated by Benni Mack over 4 years ago
- Status changed from New to Needs Feedback
Just to clear this up:
page.meta.author.data = author
page.meta.keywords.data = keywords
page.meta.description.data = description
This would/should never ever work:
https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/DataTypes/Index.html#gettext
When using .data - you need to have "page:author" or "field:author" (depending on the current data, which is correct in the case of page.meta).
Looking at your examples, Riccardo, the rest of the results look fine IMHO.
Updated by Riccardo De Contardi over 4 years ago
Hello Benni, I report here again the results for each test for clarity, discarding the one with incorrect syntax:
1) This one still looks faulty , the value of description from the page is always taken even if I have just defined the constants.
Why only description behaves like that? Is it correct?
Test | Page A | Page B | Page C | Page D |
---|---|---|---|---|
only page.meta.author = {$page.meta.author} page.meta.keywords = {$page.meta.keywords} page.meta.description = {$page.meta.description} |
C C P | C C P | C C C | C C C |
2) These ones look correct: the override with the values from page is always done when present - and they're totally equivalent
Test | Page A | Page B | Page C | Page D |
---|---|---|---|---|
Added:page.meta.author.override.field = author page.meta.keywords.override.field = keywords page.meta.description.override.field = description |
P P P | C C P | P P C | C C C |
Added:page.meta.author.override.data = page:author page.meta.keywords.override.data = page:keywords page.meta.description.override.data = page:description |
P P P | C C P | P P C | C C C |
Added:page.meta.author.stdWrap.override.data = page:author page.meta.keywords.stdWrap.override.data = page:keywords page.meta.description.stdWrap.override.data = page:description |
P P P | C C P | P P C | C C C |
Added:page.meta.author.data = page:author page.meta.keywords.data = page:keywords page.meta.description.data = page:description |
P P P | / / P | P P / | / / / |
4) Last but not the least, this looks good, too, it is the same as the previous one, plus the "slide" is correctly considered
Test | Page A | Page B | Page C | Page D |
---|---|---|---|---|
Added:page.meta.author.data = levelfield:-1, author, slide page.meta.keywords.data = levelfield:-1, keywords, slide page.meta.description.data = levelfield:-1, description, slide |
P P P | / / P | P P / | / / / |
same configuration of the previous line; checked the subpage of each page | P P P | / / P | P P / | / / / |
Updated by Benni Mack over 4 years ago
Perfect, Riccardo!
With your information I spotted the issue, which resides in the EXT:seo MetaTagGenerator where the "description" field is always taken from the page.
Updated by Benni Mack over 4 years ago
- Status changed from Needs Feedback to Accepted
Updated by Thomas Stranz almost 4 years ago
page.meta.description.replace = 1
worked for me
Updated by Richard Haeser almost 4 years ago
For the description field it is right you need the .replace
parameter. So this is expected behaviour. If you want to override the settings with TypoScript you have to use that parameter.
If I'm right we can close this issue.
Updated by Richard Haeser almost 4 years ago
- Status changed from Accepted to Needs Feedback
Updated by Riccardo De Contardi almost 4 years ago
@Thomas Stranz, @Richard Haeser
I am trying unluckily without success to find where in the documentation it is stated that page.description
is a special case that needs the replace
function; (looking at https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Setup/Page/Index.html?highlight=meta#meta. Is there some other place where to search?)
Updated by Richard Haeser almost 4 years ago
Riccardo, on the link you have given, in the description of meta you find:
replace If set to 1, the tag will replace the one set earlier by a plugin. If set to 0 (default), the meta tag generated by the plugin will be used. If there is none yet, the one from TypoScript is set.
If that is not sufficient, maybe we have to update the documentation a little bit
Updated by Riccardo De Contardi almost 4 years ago
@Richard Haeser
Aw... it is embarrassing I haven't seen it :O
If that is not sufficient, maybe we have to update the documentation a little bit
I would suggest to add at least an example to make it more evident, and thanks again for finding it.
Updated by Richard Haeser almost 4 years ago
- Status changed from Needs Feedback to New