How To Make XenForo Custom Page Titles

  • Thread starter KristinaW
  • Start date


May 7, 2021
Reaction Score
  • #1
As I’ve mentioned in the past, I’m running XenForo forum software for a few of my websites. I’ll start off by saying that I absolutely love it. It’s intuitive, slick and it’s more than I could have ever hoped for. Hats off to the developers because it’s not often I see a piece of software of this quality. It’s truly outstanding.

As I’ve shared already (just search XenForo in the search up top), there are a few SEO related issues surrounding the forum software though. Most of them are very easy to deal with. Today, I’d like to discuss one that’s of moderate difficulty to deal with, but really, once you get your hands dirty, you’ll see how simple it truly is.

Okay, so what’s the problem? Well, here it is. There’s only one area to set an overall “site” page title and that title is appended to every single page of the discussion board. So, if I were to name a board (for instance): MySite Technology & Discussion Forum, that title would be on every single page. The titles would look like this:

Homepage: MySite Technology & Discussion Forum
Forum Pages: Photoshop Forums | MySite Technology & Discussion Forum
Thread Pages: What’s So Great About XenForo Forum Software? | MySite Technology & Discussion Forum

You get the idea. Basically, that homepage title gets stuck at the end of every page title in the entire site. Not an ideal situation, especially if your homepage title is around 70 characters. Unless you give your homepage the title of “MySite,” most, if not all, of your page titles will be too long and diluted. Not to mention, duplicates of one another. I’m sure the search engines won’t like that at all.

I’ve done some tinkering and have devised a way to create custom page titles so the homepage, forum pages, thread pages and all the other pages will have distinct titles. I’ve applied this method to a few of my forums and it’s working out well. I figured I’d share the custom code I wrote here.

To use this method, you’ll need to log in to your forum software admin area. Then, visit the Appearance > Templates area. After that, type “PAGE_CONTAINER” into the search filter bar up top. This will give you this specific template. This is the only one you’ll need to update.

Look for this code:

    <title><xf:title formatter="%s | %s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>

Now, replace that line of code with this:

<xf:if is="$template == 'forum_list'">
<title><xf:title formatter="%s | %s" fallback="HOMEPAGE TITLE GOES HERE" /></title>
<xf:elseif is="$template == 'forum_view'" />
<title><xf:title formatter="%s | %s" fallback="TEXT THAT WILL BE APPENDED TO THE FORUM TITLES GOES HERE" page="{$pageNumber}" /></title>
<xf:elseif is="$template == 'thread_view'" />
<title><xf:title /></title>
<xf:else />
<title><xf:title formatter="%s | %s" fallback="{$xf.options.boardTitle}" page="{$pageNumber}" /></title>

This is what you’re looking at above. Let’s break it down. In the Setup > Options area, you should give your site a short name. Maybe just your domain name. So in my case, it would be “MySite.” This name will be appended to most pages.

Next, in the replacement code above, the first section covers what the homepage title will be. Just fill in that area. Obviously, remove the HOMEPAGE TITLE GOES HERE and fill in your own information.

The second section covers the forum page titles. If you would like them to be appended with some verbiage, just type that verbiage in that section.

As for the thread titles, I decided it was best to keep them clean and only let the software name them what they’re actually called.

And finally, every other page will simply have the site title appended to it.

Let me know if this helps and let me know if you have any ideas of your own to deal with this duplicate page title issue in XenForo. Thanks!