SOLVED: (HREFLANG, Mulitlingual Support) -How to Decode HTML from custom field?
-
June 21, 2022 at 10:31 am #7632
[anonymous]
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.
June 22, 2022 at 11:56 am #7638
[anonymous]
I think I’m not understanding the process very well.
Where exactly is the header.hbs file? I only find the file head.hbs
June 22, 2022 at 3:43 pm #7639
[anonymous]
@drunkenboxer
I am trying to do the process as you say and I am not getting it to work. How do you change language? Don’t we have to add some icons with the flags or something? I have done the whole process modifying the head instead of header but it doesn’t work.
Greetings and thanks first of all
June 22, 2022 at 6:44 pm #7641
[anonymous]
seb_oi wrote:I think I’m not understanding the process very well.
Where exactly is the header.hbs file? I only find the file head.hbs
I am sorry, must be HEAD.hbs, not header.hbs. 😳
June 22, 2022 at 7:53 pm #7642
[anonymous]
seb_oi wrote:I am trying to do the process as you say and I am not getting it to work. How do you change language? Don’t we have to add some icons with the flags or something? I have done the whole process modifying the head instead of header but it doesn’t work.
Greetings and thanks first of all
I wrote a long tut for ONE possivle solution, but unfortunally wordfence does not to want to make me publish it 🙁
June 23, 2022 at 11:19 am #7651
[anonymous]
[anonymous] wrote:seb_oi wrote:I am trying to do the process as you say and I am not getting it to work. How do you change language? Don’t we have to add some icons with the flags or something? I have done the whole process modifying the head instead of header but it doesn’t work.
Greetings and thanks first of all
I wrote a long tut for ONE possivle solution, but unfortunally wordfence does not to want to make me publish it 🙁
Thank you very much for your answer. I’m waiting to see if with a bit of luck we can fix it.
And thank you very much for your solution.
August 8, 2022 at 2:33 pm #8008
[anonymous]
[anonymous] wrote:I wrote a long tut for ONE possivle solution, but unfortunally wordfence does not to want to make me publish it 🙁
Try pasting your answer using Gist. The Publii forum isn’t ideal for sharing code, unfortunately.