Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

May insert variable value into a HTML tag attribute? #1065

Closed
zfengg opened this issue Nov 25, 2023 · 2 comments
Closed

May insert variable value into a HTML tag attribute? #1065

zfengg opened this issue Nov 25, 2023 · 2 comments

Comments

@zfengg
Copy link
Contributor

zfengg commented Nov 25, 2023

For example, may I insert the value of a local variable descr = "Homepage of A Group" into the HTML meta tag like <meta property="og:description" content= $descr >?

@tlienart
Copy link
Owner

tlienart commented Nov 25, 2023

in your case, descr seems like a global variable in which case you'd put that in config.md and do:

<meta property="og:description" content="{{ descr }}" >

which will then show on all pages

if you do want this only on a single page, set the default value in config.md to empty descr = "" then on any page you want a specific value descr = "..." and in layout:

{{isnotempty descr}}
  <meta property="og:description" content="{{ descr }}" >
{{end}}

kindly close this issue if it solves your problem

@zfengg
Copy link
Contributor Author

zfengg commented Nov 25, 2023

Thank you for the clear explanation. It works! Now I see that the underlying pipeline deals with all the

{{ ... }}

and there is no difference in their positions in the pre-produced HTML.

@zfengg zfengg closed this as completed Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants