Hi folks,
I try to add some custom HTML in the header of a PAGE (so Tools -> custom HTML ist NOT working, because for whole site).
What I did:
- I added a custom post.config (textarea) like you can read here
- I customized head.hbs with code {{@config.post.addInHeader}} on the right place
- I added <link rel=”alternate” hreflang=”en” href=”https://www.example.com/en” /> in the field
- It works, but…
Problem:
HTML entities are encoded. I need to decode.
While I write, I found the solution, but I write it down here, because I saw more questions regadring HREFLANG, Multilingual, etc. This could be a solution for that!
You have to use 3 braces, not only 2:
{{{@config.post.addInHeader}}}
So, here is my solution for Multilingual Support:
- Open theme -> config.json
- Find “postConfig”-Section
- Insert code at the end of the section:
{
"name": "addInHeader",
"label": "Insert Tags in Post-Header",
"value": "",
"type": "textarea"
}
- Open C:\Users\yourUserName\Documents\Publii\sites\mypagecom\input\themes\ (How to handle overrides)
- Create folder {{theme}}-override
- Copy sites\mypagecom\input\themes\<span style=”color: #ff0000;”>{{theme}}</span>\partials\header.hbs to sites\mypagecom\input\themes\<span style=”color: #339966;”>{{theme}}-override</span>\partials\header.hbs
- Add {{{@config.post.addInHeader}}} directly before closing Head-Tag.
- Save, Close and RESTART publii.