TYPO3中如何通过TypoScript正确添加作者邮箱至meta标签
Since HTML5 allows the author meta tag to include both name and email in the format name, email@example.com, you can use a Content Object Array (COA) in TypoScript to merge the author name and email values from your page fields. Here's how to modify your existing code:
page = PAGE page { meta { author = COA author { # Get the author name (using your existing slide/override logic) 10 = TEXT 10 { data = levelfield :-1, author slide override.field = author } # Add comma + space only if both name and email exist 20 = TEXT 20 { value = , stdWrap.if.isTrue.field = author_email stdWrap.if.isTrue.data = levelfield :-1, author_email slide } # Get the author email (mirroring the name's slide/override logic) 30 = TEXT 30 { data = levelfield :-1, author_email slide override.field = author_email } } } }
Key Details:
- COA (10-30): This content object array lets us build the final meta content string step by step.
- Author Name (10): Reuses your existing logic to pull the author name—either from the current page or sliding up to parent pages if it's not set on the current page.
- Separator (20): Adds a comma and space only if an author email exists (either on the current page or a parent page). This prevents unwanted trailing commas when there's no email.
- Author Email (30): Mirrors the name's sliding/override logic to retrieve the email address consistently.
Edge Cases Handled:
- If only the author name exists: The meta tag will display just the name (no extra punctuation).
- If only the author email exists: The meta tag will show just the email (though pairing it with a name is recommended, this handles the scenario gracefully).
- If both name and email exist: They'll be combined in the valid HTML5 format (
name, email@example.com).
内容的提问来源于stack exchange,提问作者webman
相关产品推荐
相关产品推荐

