1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to change <title> tag for home page only?

Discussion in 'Styling and Customization Questions' started by jondoe0069, May 27, 2013.

  1. jondoe0069

    jondoe0069 Member

    I know this is probably a stupid question, but honestly, I've looked around and couldn't find much. I'm running the newest stable version and using the default theme. In the search engines, my home page title shows up as just the forum name and I'd like to add a tagline to the <title> tag to make it stand out more.

    What is the best way to do that?

  2. jondoe0069

    jondoe0069 Member

    I added the following to the forums list:

    <xen:title>Forum Name - Tagline</xen:title>

    It worked, but it put the forum name at the end, like:

    Forum Name - Tagline | Forum Name

    I want it to be:

    Forum Name - Tagline
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  4. CyclingTribe

    CyclingTribe Well-Known Member

    If you want a different title for the forums list "home" page - edit the PAGE_CONTAINER template and change the title coding from:

    <title><xen:if is="{$title}">{xen:raw $title} | {$xenOptions.boardTitle}<xen:else />{$xenOptions.boardTitle}</xen:if></title>
    ... to:

    <xen:if is="{$contentTemplate} == 'forum_list'">
        <title>CUSTOM TITLE HERE</title>
    <xen:else />
        <title><xen:if is="{$title}">{xen:raw $title} | {$xenOptions.boardTitle}<xen:else />{$xenOptions.boardTitle}</xen:if></title>
    Then add your custom title in the highlighted section.

    Shaun :D
  5. jondoe0069

    jondoe0069 Member

    Beautiful! Worked perfectly!!
    CyclingTribe likes this.
  6. Jahsun

    Jahsun Member

    Old post but the method works just the same. Thank you
    CyclingTribe likes this.
  7. ibrian

    ibrian Active Member

    Excellent - exactly what I was looking for. :)
    CyclingTribe likes this.
  8. CyberAP

    CyberAP Well-Known Member

    There is a better way to do it IMO:

    We set a new condition for title element:

            <xen:if is="{$customTitle}">{xen:raw $customTitle}
            <xen:elseif is="{$title}" />{xen:raw $title} | {$xenOptions.boardTitle}
            <xen:else />{$xenOptions.boardTitle}</xen:if>
    In our content template we can use <xen:container> to set a custom title instead. So it'll be like this:

    <xen:container var="$customTitle">My custom title</xen:container>
    Don't forget to place it before <xen:title> tag.
    thomas1 likes this.

Share This Page