ok, so I have followed the tutorials through and generally have much of this figured out, I have a single html page header chunk for all pages, so I can make major site changes to the template easily.
For each individual channel, I want custom fields for meta data, but how do I select to include these in the generic html header, when this is a separate included file on its own and just pulled into each individual channel template??
I hope that make sense 😖
Thanks for looking
You can do this the same way as you pass, for example, the title of each post. Do it with the embed. So in the embed for the HTML Header, you also pass a declared variable. Something like:
{embed="embeds/html-header" the_entry_meta_title="{exp:channel:entries channel="{your_channel_name}" orderby="date" sort="desc" dynamic="off" disable="member_data|categories|trackbacks|category_fields"}{title}{/exp:channel:entries}"}
That would pass the title of your post as a variable into your embedded HTML Header embed. then in the HTML Header, you would then used this embedded variable in the template where you need it. So you could use it in the HTML title tag, and you could also use it in the meta title tag. Where ever you need the title to appear, you just use:
{embed:the_entry_meta_title}
And you can repeat this approach with other fields, such as a meta description or meta keywords list. They just need to be part of your field group for the channel in question.
In addition to this approach, i usually also setup a default list, which is stored separately - basically adding an “IF” statement that says if there is a value for this field, use it, and if there is not, use this default value instead. That’s a bit more work to setup, but if you’re not confident that the meta data will be remembered each and every time an entry is added, at least then you have something going into the meta data tags and it’s not leaving them blank.
That’s just how I have done it though. Other EE’ers may have other suggestions.
Hope that helps,
John