Search

How to Add Extra Descriptions to XenForo Forum Pages

  • Thread starter JGaulard
  • Start date
JGaulard

JGaulard

Administrator
Staff member
Site Supporter
Sr. Site Supporter
Power User
Joined
May 5, 2021
Messages
319
Reaction Score
2
Points
18
  • #1
If you've been involved with websites and SEO for any amount of time, you most likely know that category (forum) pages can actually rank in the search engines if they've got some nice, full, unique (well researched and written) content on them. In many cases on websites such as forums, classifieds, and ecommerce stores, category pages right out of the box offer nothing more than lists of links to other pages. In recent years, high-end SEO professionals have begun adding content to their category pages themselves in an effort to rank them for bigger and more valuable search terms. To show you what I'm referring to, take a look at these example sites:

https://www.jpcycles.com/motorcycle-engines (down at the bottom of the page)
https://www.ebay.com/b/Bikes/177831/bn_1865335 (towards the bottom of the page)

It's these descriptions that the search engines will crawl, read, and add to their keyword lists.

One thing: when I use the phrase category pages, I also mean forum pages in the XenForo system. Within XenForo, you've basically got a homepage, forum pages (category pages), and thread pages. Forum pages are pretty much the same thing as category pages.

On this very website (gaulard.com), I've added some additional descriptions to the forum pages in an effort to help the pages rank. At the time of this writing, I've only just begun writing the descriptions out. Eventually, I'll have long and informative ones, but for now, I've got only a few sentences on only a few pages. As an example of this, please take a look at the bottom of this page:

https://gaulard.com/forum/forums/9/

Also, when I say description, I'm not referring to a meta description. I'm merely referring to a chunk of text on a page that will offer some information.

The question is, how did I add these additional descriptions to the forum pages? As it stands, default XenForo installations only allow one description per forum and that goes right under the title of the page. How did I get that second one in there? The answer to that is to use some custom code as well as some advertisement placements. We don't need any addons at all for this task.

I'll begin with the custom code. The goal is to add the additional description only to the first page of the forum. We don't want the description showing on each and every paginated page. Some forums have thousands of pages in them and it's not wise to repeat the same text on all of them. To show only the description on page one, we'll need to use a conditional statement. Take a look:

Code:
<xf:if is="$__globals.page == '1'">

Some description text.

</xf:if>

The above code says, if it's the first page of the forum, show the contained text.

But wait, if this was the only code used, the same exact description text would show on the first page of every single forum on the website. That's not what we want, so we need to define which forum we want the description to appear in.

Code:
<xf:if is="$__globals.page == '1'">
<xf:if is="$forum.node_id == 9">

Some description text.

</xf:if>
</xf:if>

Now we're getting somewhere. In the above code, I added the id of the forum I want the description text to appear. How did I find the forum id? That's easy. I visited the forum page and looked at the URL. This is the forum URL for the example I'm using above:

https://gaulard.com/forum/forums/9/

See the "9" in there? For each and every forum we'd like to add an additional description box to, we'll need to create custom code with the forum's unique id.

On my Photography page, I have my description contained in a neat white box. To add this box, I used some simple CSS. This is the final code:

Code:
<xf:if is="$__globals.page == '1'">
<xf:if is="$forum.node_id == 9">
<div style="padding:10px; margin:10px 0 20px 0; border-bottom:1px solid #dedede; border-top:1px solid #dedede; background:#ffffff; color:#141414; font-size: 1em;">
  
Some description text.

</div>
</xf:if>
</xf:if>

That's all for the custom code. Now we need to find a place to put it. I'll show you how I added it to the bottom of the forum page in question.

To add the code to the site, I logged into me site's admin panel and then navigated to Setup > Advertising. Then, I clicked the Add Advertisement button. Once on the new advertisement page, I created a Title of Description: Photography. You can put whatever you want. This worked for me. Next, I defined the Position as Forum View: Below Thread List. In the HTML box, I added the final custom code from above. I kept everything else on the page as is and then I pressed the Save button. That's all there is to the process. After that, the additional description appeared on my Photography forum page. To add additional text to the various forums on my site, I repeated the above process (with new advertisement placements) for each one, changing the forum id as well as the text.

I hope I clearly explained this process. If you have any questions or if something was unclear, please ask me any questions below. Thanks!
 
Top