Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

SOLVED: (HREFLANG, Mulitlingual Support) -How to Decode HTML from custom field?

  • #7632
    Avatar photo[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&#8221; /> 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:

    1. Open theme -> config.json
    2. Find “postConfig”-Section
    3. Insert code at the end of the section:
      {
          "name": "addInHeader",
          "label": "Insert Tags in Post-Header",
          "value": "",
          "type": "textarea"        
      }
      
    4. Open C:\Users\yourUserName\Documents\Publii\sites\mypagecom\input\themes\ (How to handle overrides)
    5. Create folder {{theme}}-override
    6. 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
    7. Add {{{@config.post.addInHeader}}} directly before closing Head-Tag.
    8. Save, Close and RESTART publii.
    #7638
    Avatar photo[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

    #7639
    Avatar photo[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

    #7641
    Avatar photo[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.  😳

    #7642
    Avatar photo[anonymous]
    seb_oi wrote:

    @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

    I wrote a long tut for ONE possivle solution, but unfortunally wordfence does not to want to make me publish it 🙁

    #7651
    Avatar photo[anonymous]
    [anonymous] wrote:
    seb_oi wrote:

    @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

    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.

    #8008
    Avatar photo[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.