SEO for PHPBB3 – Site Title, Meta Keywords and Meta Descriptions

Posted in Web Development on 13 November 2009 5 comments

No offence, but the fact is phpBB has a lot of weaknesses, not seo-friendly being one of them. However, with some simple steps you can improve the SEO of your phpBB. Here in this guide, we will add some basic SEO features to your phpBB by using a better Site Title, adding Meta Keywords and Meta Descriptions. I am using phpBB 3.0.5 for this guide.

A Better Site Title

This is the default site title for phpBB subSilver2 theme.

<title>{SITENAME} &bull; <!-- IF S_IN_MCP -->{L_MCP} &bull; <!-- ELSEIF S_IN_UCP -->{L_UCP} &bull; <!-- ENDIF -->{PAGE_TITLE}</title>

According to the codes above, no matter where you are, your site name would be shown first. This is recommended for your main forum index, but not for viewforum and viewtopic. For better SEO, your forum title or topic title should appear first. That can be achieved by the following codes.

Open your template’s overall_header.php, look for <title></title> tags (like above) and replace it with the following :

<title><!-- IF S_IN_MCP -->{L_MCP} &bull; <!-- ELSEIF S_IN_UCP -->{L_UCP} &bull; <!-- ENDIF -->
   <!-- IF SCRIPT_NAME == "index" -->{SITENAME} - {SITE_DESCRIPTION}
   <!-- ELSEIF SCRIPT_NAME == "viewforum" -->{FORUM_NAME} | {SITENAME}
   <!-- ELSEIF SCRIPT_NAME == "viewtopic" -->{TOPIC_TITLE} | {SITENAME}
   <!-- ELSEIF SCRIPT_NAME == "posting" --><!-- IF S_USER_LOGGED_IN --><!-- IF TOPIC_TITLE -->{L_TOPIC} - {TOPIC_TITLE}<!-- ELSE -->{L_FORUM}<!-- IF FORUM_NAME --> - {FORUM_NAME}<!-- ENDIF --><!-- ENDIF --><!-- ELSE -->{SITENAME}<!-- ENDIF -->
   <!-- ELSEIF SCRIPT_NAME == "ucp" -->{L_VIEWING_UCP} - {PAGE_TITLE}<!-- IF CUR_FOLDER_NAME -->{CUR_FOLDER_NAME}<!-- ENDIF -->
   <!-- ELSEIF SCRIPT_NAME == "mcp" -->{L_VIEWING_MCP}<!-- IF PAGE_TITLE --> - {PAGE_TITLE}<!-- ENDIF --><!-- IF L_TITLE --> - {L_TITLE}<!-- ENDIF -->
   <!-- ELSEIF SCRIPT_NAME == "faq" -->{L_VIEWING_FAQ} - {L_FAQ_TITLE}
    <!-- ELSEIF SCRIPT_NAME == "search" -->{L_SEARCH} <!-- IF SEARCH_TITLE --> - {SEARCH_TITLE}<!-- ENDIF --><!-- IF SEARCH_MATCHES --> - {SEARCH_MATCHES}<!-- ENDIF --> | {SITENAME}
   <!-- ELSEIF SCRIPT_NAME == "memberlist" --><!-- IF S_USER_LOGGED_IN -->{PAGE_TITLE}
    <!-- IF S_SHOW_GROUP --> - {GROUP_NAME}<!-- ENDIF --> | {SITENAME}<!-- ELSE -->{SITENAME}<!-- ENDIF -->
   <!-- ELSEIF SCRIPT_NAME == "chat" -->{L_VIEWING_CHAT}
   <!-- ELSE -->Viewing Undefined page<!-- ENDIF --></title>

This is an edited version of codes taken from another website (I forgot). I found this site title suits me well. Change things around to suit your need.

Now here’s how your site title looks like:

Forum index : Site Name – Forum Description
View Forum : Forum Title | Site Name
View Topic : Topic Title | Site Name

Adding Meta Descriptions

Also in overall_header.php, add this at anywhere in the <head> tag.

<meta name="description" content="<!-- IF SCRIPT_NAME == "viewforum" -->{FORUM_DESC}
<!-- ELSEIF SCRIPT_NAME == "viewtopic" -->{MESSAGE_TRIMMED}<!-- ELSE -->YOUR DEFAULT META CONTENT<!-- ENDIF -->" />

Replace the “YOUR DEFAULT META CONTENT” with the meta description of your site. It will be used on pages when its not viewforum or viewtopic.

MESSAGE_TRIMMED is undefined, yet.

As you can see the template tag {MESSAGE_TRIMMED} is undefined. {MESSAGE_TRIMMED} is a new template tag that should carry not more than 150 characters of the content of first post because most search engines use a maximum of 160 characters for the description.

Open your_phpbb_root/viewtopic.php, look for:

define('IN_PHPBB', true);

Replace with:

$zvloop = 0;
define('IN_PHPBB', true);

Next, look for:

if (isset($cp_row['row']) && sizeof($cp_row['row']))

If you can’t find the line, stop finding and paste the codes below after the big $postrow array. if you found it, paste this codes below before the line:

  if ($zvloop == 0) {
    $zv_topic_trimmed = substr(strip_tags($postrow['MESSAGE']),0,150);
  $zvloop++;
  }

Lastly, look for:

// Output the page
page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title']);

Replace it with:

$template->assign_vars(array(
	'MESSAGE_TRIMMED' => $zv_topic_trimmed
));
 
// Output the page
page_header($user->lang['VIEW_TOPIC'] . ' - ' . $topic_data['topic_title']);

That’s it for meta description.

Adding Meta Keywords

Although meta keywords is not important anymore, there’s no harm adding it.

Paste this after your meta description and change the keywords. It wll be used throughout your forum so use suitable keywords.

<meta name="keywords" content="seperate,your,keywords,using,comma,without,any,blank,space" />

Any comments or corrections are welcomed.

Posted by zen   @   13 November 2009 5 comments
Tags :


  - 5 Comments


Kevin says:

Thanks, I was actually looking for something like this…and I found it!

Mark says:

Thank you for the great article! Following these simple steps was about 20x easier than a) trying to find a MOD compatible with my bb b) trying to install that mod and c) trying to configure that mod.

Thanks!!

US says:

I’is good thank you

webforums says:

Very useful and effective guide. Exactly the one I was looking for.
Thank You

Ashutosh says:

Excellent Post Man……Thank You Very Much….Good To see that there are so much people who don’t hesitate to share the knowledge.

Leave a Reply

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Please wrap all source codes with [code][/code] tags. Powered by Source Codes in Comments
Previous Post
« 17 Gorgeous Wood Productions by The Wood Man
Next Post
Create SEO Friendly URLs With Htaccess Mod Rewrite in 3 Easy Steps »