Language:

Search

Snippet - Cómo corregir la duplicación de títulos en Timber Site

  • Share this:
Snippet - Cómo corregir la duplicación de títulos en Timber Site

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.

Usama Muneer

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.