1
wishcraft
Page Titles and Meta Keywords - SEO Tip #2

Well I have decided after my recent post to share some SEO tips with you.. This one is to do with titles and your keywords, see if you keywords reflect the title of your page you will be given a higher rank in the search engines than a page with similar common keywords. This is a direct method of address this site wide with only a few lines of code.

In your theme.html you will have a meta keyword field it will currently look like:

<meta name="keywords" content="<{$xoops_meta_keywords}>" />


You will need to add this bit of code to it to include your sitename and page title in the keywords allowing for a better rank..

<meta name="keywords" content="<{php}>$pg_title = $this->_tpl_vars['xoops_pagetitle'].','.$this->_tpl_vars['xoops_sitename'];
    
$pg_title = str_replace(' ',',',$pg_title);
    
$pg_title = str_replace('-',',',$pg_title);
    
$pg_title = str_replace('|',',',$pg_title);
    
$pg_title = str_replace(':',',',$pg_title);
    
$pg_title = str_replace('=',',',$pg_title);
    
$pg_title = str_replace('&',',',$pg_title);
    
$pg_title = str_replace(')','',$pg_title);
    
$pg_title = str_replace('(','',$pg_title);
    
$pg_title = str_replace('[','',$pg_title);
    
$pg_title = str_replace(']','',$pg_title);
    
$pg_title = str_replace('{','',$pg_title);
    
$pg_title = str_replace('}','',$pg_title);
    
$pg_title = str_replace('and',',',$pg_title);
    
$pg_title = str_replace('the',',',$pg_title);
    
$pg_title = str_replace(',,',',',$pg_title);
    
$pg_title = str_replace(',,',',',$pg_title);
    
$pg_title = str_replace(',,',',',$pg_title);
    echo 
$pg_title;<{/php}>,<{$xoops_meta_keywords}>" />


isn't smarty great you can alter one file and have your site wide a keyword spread that offer better ranking as all the keywords of the title of the page come first.

There you go

Later Yall!!
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

2
wishcraft
Re: Page Titles and Meta Keywords - SEO Tip #2

a better version of this code is:

<meta name="keywords" content="<{php}>$pg_title = $this->_tpl_vars['xoops_pagetitle'].','.$this->_tpl_vars['xoops_sitename'];
    
$pg_title = str_replace(' ',',',$pg_title);
    
$pg_title = str_replace('-',',',$pg_title);
    
$pg_title = str_replace('|',',',$pg_title);
    
$pg_title = str_replace(':',',',$pg_title);
    
$pg_title = str_replace('=',',',$pg_title);
    
$pg_title = str_replace('&',',',$pg_title);
    
$pg_title = str_replace(')','',$pg_title);
    
$pg_title = str_replace('(','',$pg_title);
    
$pg_title = str_replace('[','',$pg_title);
    
$pg_title = str_replace(']','',$pg_title);
    
$pg_title = str_replace('{','',$pg_title);
    
$pg_title = str_replace('}','',$pg_title);
    
$pg_title = str_replace(' and ',',',$pg_title);
    
$pg_title = str_replace(' the ',',',$pg_title);
    
$pg_title = str_replace(',,',',',$pg_title);
    
$pg_title = str_replace(',,',',',$pg_title);
    
$pg_title = str_replace(',,',',',$pg_title);
    
$pg_title .= ",".$this->_tpl_vars['meta_keywords'];
    
$pg_array = explode(",",$pg_title);
    
$pg_array = array_unique($pg_array);
    echo implode("
,",$pg_array);<{/php}>" />
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

3
mboyden
Re: Page Titles and Meta Keywords - SEO Tip #2
  • 2008/1/9 15:51

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


One small error in this second set of code. Change:

$pg_title .= ",".$this->_tpl_vars['meta_keywords'];

to:

$pg_title .= ",".$this->_tpl_vars['xoops_meta_keywords'];
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

4
phppp
Re: Page Titles and Meta Keywords - SEO Tip #2
  • 2008/1/9 15:54

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


I haven't looked insight but a very wild guess:
can you turn it into some smarty plugin?

5
mboyden
Re: Page Titles and Meta Keywords - SEO Tip #2
  • 2008/1/9 16:01

  • mboyden

  • Moderator

  • Posts: 484

  • Since: 2005/3/9 1


One other comment on this, too, before we head down the path of making code for this since I found for my home pages I had the same keywords in it repeated. I think most people put in the XOOPS preferences keywords their site name and slogan which would make them repeat here. Well, okay, at least I do.

Also, most of the modules I've seen that edit the $xoops_meta_keywords value seems to add their keywords instead of replacing them. And since you can get penalized for repeating words too much, this might NOT be the best idea.

However, assuming we include this, Smarty-izing the function might be the way to go.
Pessimists see difficulty in opportunity; Optimists see opportunity in difficulty. --W Churchill

XOOPS: Latest | Debug | Hosting and Web Development

6
wishcraft
Re: Page Titles and Meta Keywords - SEO Tip #2

yeah your right about that minor error in the meta_keywords function to the standard xoops_meta_keywords sorry I copied the code from the multixoops I put together for my SEO experiment in XOOPS and escorting websites I hacked together from 2.0.13 - 2.0.16; which has a few extra and amendments to it.

Umm with the second version of the code you shouldn't have repeats in the keywords as it has this clause:

$pg_array = array_unique($pg_array);

array_unique will strip duplicates from the array then implode it back to a string with the implode function. yeah I found that in the first version of the code that there where duplicates so I decided to implement array_unique which will strip out duplicates.

This changes the keyword density of the the site so your pages don't have the same keywords on every page and every search engine goes, 'well thats keyword stuffing' at least this is what I am told it is called or one of the versions of that is called, and marks you down a bit.

ps. Thanks for the invite
Resized Image
http://www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/RegaltyFamily
github.com/Chronolabs-Cooperative
facebook.com/DrAntonyRoberts

Login

Who's Online

142 user(s) are online (31 user(s) are browsing Support Forums)


Members: 0


Guests: 142


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits