Sign in

Editing HTML Code of title in WYSIWYG Post Editor

  • This topic has 3 replies, 2 voices, and was last updated 1 week, 4 days ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #6213
    candidexmedia

    Hello!

    Is there any way to edit the html source code of the title of a post, the same way you can edit the content of the post in the WYSIWYG Editor?

    I would like to be able to add <br> and <span> tags to the titles of individual posts for further customization inside the post editor, without affecting other posts by editing the template or creating an entire template just for that one post.

    #6257
    Tomasz Dziuda

    Hi,

    In fact you can use HTML in the title, but then you have to modify your theme to allow HTML in the title – by default you have:

    {{title}}

    while you need:

    {{{title}}}

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #6303
    candidexmedia

    Hi,

    In fact you can use HTML in the title, but then you have to modify your theme to allow HTML in the title – by default you have:

    {{title}}

    while you need:

    {{{title}}}

    Thank you for your help Tomasz!

    Changing {{title}} to {{{title}}} does indeed help with adding HTML tags to the title. However, these HTML tags are kept in other parts of the template, such as post navigations and previews.

     

    For example, if I make the title of a post “My Title: <br><br> My subtitle” and configure {{{title}}} in the post template .hbs file, it will add the breaks on the post page, but on another article, in the “previous article” or “next article” section, the title of this post will be displayed as “My Title: <br><br> My subtitle”.

    If I change the {{title}} in the post navigation to {{{title}}}, it will add a line break in the post navigation. However, I only wanted this styling for the post itself.

    Is there any way to circumvent this? For instance, there’s a section in the Post Setting > SEO options, under “Page Title” that allows you to set a custom post title for the browser tab, which avoids the above issue for browser tabs.

    #6304
    candidexmedia

    I think I’ve solved my own issue. I’m sharing the solution here for anyone it might help:

    I went into the post.hbs file (or whatever custom post file) and removed/commented out the following code at the top:

    <h1>
    {{title}}
    </h1>

    I then went into my post in the post editor and added the title manually, making sure to surround it with h1 tags using the HTML edit button and add whatever styling I want.

    This way, I can style my title however I want in the post itself (inside of the post’s text editor), and it remains unformatted in other sections of my site where the title is used.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.