Copy link to clipboard
Copied
Can we with Liquid pass variables to the template file?
For this case I want to to pass blog post title, description etc. into the <head> of my template to use the Facebook OG-graph meta tags.
Thanks!
Copy link to clipboard
Copied
To pass liquid variables from pages or templates into module templates like web apps or product layouts you need to output the list as a collection on the page or use a liquid include in conjunction with a collection. Liquid variables do not pass through to module templates/layouts. Otherwise you'll have to declare your variable within the module template file.
In your example though why wouldn't you just use the built in blog modules metadata fields and insert as tags or liquid tags in the detail layout? If you wanted to specify meta data that will be the same for each blog post then you should probably just create a new template and hard code that information in the <head>
Copy link to clipboard
Copied
Scott, I want to pass it into the page template. Facebook/Twitter/LinkedIn all have special meta tags. The client dosn't want to write manual code, they just want to fill in the standard meta and get the data copied into the other meta-tags by the template file.
Copy link to clipboard
Copied
Sorry, if i'm still not understanding but if you're using the built-in blog module in bc this is what your blog post layout would look like. BC will kick the meta tag information into the <head> of your page template then. If you need to fill in more social media meta information, like image, you might want to go with a web app blog option.
<html>
<head>
<title>{{metaTitle}}</title>
<meta name="description" content="{{metaDescription}}">
<meta property="og:site_name" content="Site Name">
<meta property="og:type" content="article">
<meta property="og:title" content="{{title}}">
<meta property="og:url" content="{{url_withhost}}">
<meta property="og:description" content="{{metaDescription}}">
<meta property="article:publisher" content="https://www.facebook.com/companypage">
<meta name="twitter:site" content="@companyhandle">
<meta name="twitter:title" content="{{title}}">
<meta name="twitter:description" content="{{metaDescription}}">
</head>
<body>
<h1>{{title}}</h1>
{{body}}
</body>
</html>
Copy link to clipboard
Copied
Thanks for your suggestion, unfortunately it doesn't work.
It outputs:
<meta property="og:url" content="{{url_withhost}}">
<meta property="og:description" content="{{metaDescription}}">
The liquid tags is not available. That is my question - how do I pass liquid variables into the template head?
Copy link to clipboard
Copied
This is an issue I'm having as well with social meta tags in page templates.
Copy link to clipboard
Copied
Read what I put.
You place head code at the bottom of your large layout, blog, web app, product.... Any of those.
Then put your meta in there with the tags / liquid ouput items available in that layout. BC will put them in the head on page render.
Copy link to clipboard
Copied
I can confirm what Liam is saying here.
For all my blogs, product detail pages and some web app detail pages (where necessary), by simply adding your <meta property="og:xxx"> into the <body> of the detail page, BC's rendering will automatically place all <meta> tags into the <head> section of your website.
It's a brilliant feature in BC, one which has been around for several years now.
This should work very well for you.
Copy link to clipboard
Copied
Scott,
What you said is not actually 100% ![]()
{module_webapp mycustomvar="WHATEVERLIQUIDTHINGIAMPASSING" ....
Will allow this.params.mycustomvar to work in the module.
Antun,
<head>
STUFF HERE
</head>
- If a blog put that in your detail layout, use the blog tags available, you will not be able to do an image of course
- Do not need or: url unless your doing something custom with lists - they will pick it up, same with meta description
- For a web app if it has image field you can do that and anything else and again put it in your detail layout
And so on, these will be pushed into the actual head of the rendered page by BC.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more