Using Global Data File Variables To Populate .njk Meta <Title>? #2018
Unanswered
chrisativonne
asked this question in
Q&A
Replies: 1 comment
-
You probably want
https://www.11ty.dev/docs/data-computed/
…On Sat, Oct 9, 2021 at 2:14 PM Chris ***@***.***> wrote:
Is it possible to use variables from my global title file in the <title>
meta?
Example: I have a company.json file in _data that includes my company
name, tagline, phone number. I'd like to be able to use these in the title
meta of my content pages.
e.g. layout: default
title: '{{ company.name }} | {{ company.tag_line }} | {{
company.telephone }}'
When I add this the title in browser literally shows as {{ company.name
}} | {{ company.tag_line }} | {{ company.telephone }} instead of the values
from the file.
If instead I remove the quotes I get this on restarting 11ty
YAMLException was thrown:
YAMLException: can not read a block mapping entry; a multiline key may not
be an implicit key at line 4, column 1:
If I test just one of the objects by itself it shows up as a literal {{
company.name }}.
Can this be done?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2018>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEIGRYGYLWPTLW467R3HODUGCV7NANCNFSM5FVV4KJA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to use variables from my global title file in the <title> meta?
Example: I have a company.json file in _data that includes my company name, tagline, phone number. I'd like to be able to use these in the title meta of my content pages.
e.g.
layout: default
title: '{{ company.name }} | {{ company.tag_line }} | {{ company.telephone }}'
When I add this the title in browser literally shows as {{ company.name }} | {{ company.tag_line }} | {{ company.telephone }} instead of the values from the file.
If instead I remove the quotes I get this on restarting 11ty
YAMLException
was thrown:YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 4, column 1:
If I test just one of the objects by itself it shows up as a literal {{ company.name }}.
Can this be done?
Beta Was this translation helpful? Give feedback.
All reactions