Snippet – How to fix title duplication in Timber Site

Last Updated at : January 2, 2018 By - Usama Muneer | 1558

    Timber uses Twig template engine for maintaining all the view files inside of WordPress theme. For specifying the title of each page, by default, we’d something like this:

    {% if wp_title %}
        {{ wp_title }} - {{ site.name }}
    {% else %}
        {{ site.name }}
    {% endif %}

    This will do the trick but in some cases, when you’re using some SEO plugin alongside, you may notice the duplication of titles in the source. If so, here’s a quick fix for the issue.

    {% if wp_title %}
        {{ fn('wp_title','') }} - {{ site.name }}
    {% else %}
        {{ site.name }}
    {% endif %}

    For vanilla WordPress, it would be something like this:

    <title> <?php wp_title(''); ?> </title>

    Try it out and let us know in the comments section below if this trick fixed your issue of title duplication.

    Follow us on Twitter.

    blog user
    Usama Muneer

    A web enthusiastic, self-motivated & detail-oriented professional Full-Stack Web Developer from Karachi, Pakistan with experience in developing applications using JavaScript, WordPress & Laravel specifically. Loves to write on different web technologies with an equally useful skill to make some sense out of it.

    Related Posts

    Modern brands have an entire selection of platforms which they can use to build their online presence and establish themselves as a relevant entity in their industry, and yet, WordPress remains high on the list of platforms most frequently chosen for precisely this purpose.

    Do you know that a lot of websites close down their operations permanently because sufficient people do not search for them?

    In this guide, you will learn 7 free powerful ways to promote your website in 2019. These strategies are really powerful if you apply them.

    There’s an ongoing debate discussing whether SEO is relevant or not. This debate has become going on ever since search engine optimization became a powerful strategy in the digital marketing world.