Miscellaneous ⇒ Search Engines ⇒ A Meta Tags enhancement I made for news ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexSearch Engines

A Meta Tags enhancement I made for news Reply to topic


I added the following to my news module's article.php file.

The code needs to be before the line:
require_once('header.php');

What it does is dynamically generate the keywords and description header tags with data from the article instead of the current same info for every page.

For me its working well. Thought I'd share.

If you have any suggestions or see any flaws, please say so.

//Process Meta Tags //hack by spacebar for GotPoetry.com //09/15/2007 //Generate dynamic description $order = array("\r\n", "\n", "\r"); $replace = ' '; // Processes \r\n's first so they aren't converted twice. $new_desc = str_replace($order, $replace,strip_tags($hometext)); $order = array('"'); $replace = ' '; // Processes " so tags work. $new_keywords = str_replace($order, $replace,$new_desc); $METATAGS['description'] = substr($new_keywords,0,255); //Generate dynamic keywords $new_keywords = " ".$new_keywords." "; $new_keywords = strtolower("article news story " . $story['cattitle'] . " " . $story['title'] . " " . $new_keywords); //Remove common words $order = array(" a "," about "," after "," against "," all "," almost "," also "," am "," an "," and "," another "," any "," are "," around "," as "," at "," b "," be "," because "," been "," before "," behind "," being "," both "," but "," by "," c "," came "," come "," comes "," could "," d "," did "," do "," does "," done "," e "," each "," either "," etc "," ever "," every "," example "," f "," few "," for "," from "," g "," go "," h "," had "," has "," have "," here "," how "," however "," i "," if "," ii "," iii "," in "," include "," included "," including "," into "," is "," it "," its "," iv "," ix "," j "," just "," k "," l "," m "," many "," may "," midst "," might "," my "," n "," nbsp "," neither "," never "," next "," no "," nor "," not "," now "," o "," of "," often "," on "," once "," or "," other "," others "," our "," over "," p "," put "," q "," r "," s "," same "," shall "," should "," since "," so "," some "," something "," sometimes "," soon "," such "," t "," than "," that "," the "," their "," them "," then "," there "," these "," they "," this "," those "," through "," to "," too "," toward "," u "," under "," underneath "," until "," us "," use "," used "," uses "," using "," usually "," v "," very "," vi "," vii "," viii "," w "," was "," we "," went "," were "," what "," when "," where "," whether "," which "," while "," who "," why "," with "," within "," without "," would "," x "," xi "," xii "," xiii "," xiv "," xix "," xv "," xvi "," xvii "," xviii "," xx "," y "," you "," your "," z "); $replace = ' '; $new_keywords = str_replace($order, $replace,$new_keywords); //remove duplicate words $new_keywords = preg_replace("/([,.?!])/"," \\1",$new_keywords); $parts = explode(" ",$new_keywords); $unique = array_unique($parts); $unique = implode(" ",$unique); $unique_keywords = preg_replace("/\s([,.?!])/","\\1",$unique); //Remove punctuation, etc $order = array(" "," ",",",".",":",":","!","(",")"); $unique_keywords = str_replace($order, " ",$unique_keywords); //make CSV list $order = array(" "); $replace = ','; $unique_keywords = str_replace($order, $replace,$unique_keywords); $unique_keywords = str_replace(",,", ",",$unique_keywords); if (substr($unique_keywords,0,1) == ",") { $unique_keywords = substr($unique_keywords,1); } if (strlen($unique_keywords) > 5) { $METATAGS['keywords'] = $unique_keywords; }

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Unix / 2.0.46 (Red Hat) / 0.9.7a / 4.1.9-standard / 4.3.2 / 9.0.6.1


Does this output a max number of keywords?
Will it grab keywords from the entire article or just from the ingress?
I just don't want google to ban me for spamming keywords...

I have been wanting something like this so if it works well I'm happy Smile

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux 2.4.28 - Linux srv60 2.6.12.6 / Apache / 4.0.22 - 4.1.22 - 5.0.22 -5.0.32 / 4.3.11 - 4.4.2 - 4.4.4 - 5.2.5 / 9.0.6.1 - 9.1.2.1 - 9.2.0.RC2


Tried it and all I got from it was a direct copy of the title line as a keyword line. Won't google be searching the title line anyway when searching for keywords?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux 2.4.28 - Linux srv60 2.6.12.6 / Apache / 4.0.22 - 4.1.22 - 5.0.22 -5.0.32 / 4.3.11 - 4.4.2 - 4.4.4 - 5.2.5 / 9.0.6.1 - 9.1.2.1 - 9.2.0.RC2


PoKo wrote
Tried it and all I got from it was a direct copy of the title line as a keyword line. Won't google be searching the title line anyway when searching for keywords?


The code takes your title plus your category name plus the entire article and removes the duplicates plus the common words. So do you have text in your article?

Give me a URL and I'll take a look.

I don't think Google will ban your for keyword spamming because your article has all of the keywords you use in it. Does anyone else know otherwise?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Unix / 2.0.46 (Red Hat) / 0.9.7a / 4.1.9-standard / 4.3.2 / 9.0.6.1


Sorry - I removed everything again right after testing it. My site is in norwegian so I had to change all the words into norwegian and I didn't save it. I'll see if I can do it again in a few days.

Anyway, I didn't get any content from the article in the meta tags except from what was in the article header and as you said the category name.

On the other note I have read so many times about google (and others) banning sites that uses too many key words, so this is infact maybe a good thing. If this script should work perfectly it should get keywords from the ingress part of the article only, and limmit it to max 10 words, imo since I do belive that search engines will also index the title line as it is.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux 2.4.28 - Linux srv60 2.6.12.6 / Apache / 4.0.22 - 4.1.22 - 5.0.22 -5.0.32 / 4.3.11 - 4.4.2 - 4.4.4 - 5.2.5 / 9.0.6.1 - 9.1.2.1 - 9.2.0.RC2


IMO spacebar is on safe ground as far as Google penalties go.

Unlike some search engines, Google no longer uses meta keywords as a major determinant of page ranking. However, it does use them to determine spamming penalties, if keywords do not appear in page content. However, the search engines do ignore or reduce the weight of a given keyword if there are excessive keywords present.

In terms of adsense, I am not aware of any penalties from spacebar's practice. In terms of your site's SEO, I could not recommend excessive use of keywords - it will hurt you in search engine page assessments.

In summary, I think you make a choice between attracting more relevant ads and reducing your site's appeal to search engines, but remember, spacebar is only doing this on a News article basis.

A possible enhancement would be to ignore words stored in the forums stopwords list (and add to that list), plus simply ignore any word with 3 characters or less, much like the forums search function.

Note: a very useful topic and discussion, so moved to "Search Engines" forum.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


A possible enhancement would be to ignore words stored in the forums stopwords list (and add to that list), plus simply ignore any word with 3 characters or less, much like the forums search function.


Could someone explain what the forum's stopwords list does?

I can certainly make both of these changes. Should the number of keywords be limited to a lesser number?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Unix / 2.0.46 (Red Hat) / 0.9.7a / 4.1.9-standard / 4.3.2 / 9.0.6.1


"forums stopwords list (and add to that list)"

I've been looking into this and realize I don't know what table this is or how to reference it.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Unix / 2.0.46 (Red Hat) / 0.9.7a / 4.1.9-standard / 4.3.2 / 9.0.6.1


The forums stopwords list can be found in,
language/your_lang/Forums/search_stopwords.txt

It is used by,
modules/Forums/search.php
includes/phpBB/functions_search.php

Essentially it is matched against any words used in a search to preclude those words being added to the cms_bbsearch_wordlist table.

You may find the code in those files handy for adapting something.

Keywords limit? Personally yes, but you will get as many answers as there are SEO experts as to how many - anywhere between 10 and 30, but I would lean towards the lower end of the range, like 15. In your case it is not critical for the reasons I explained above.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Phoenix wrote
However, it does use them to determine spamming penalties, if keywords do not appear in page content


So when the module names are beeing used as keywords, (News, articles) and the article does not use these words at all, then it can be thought of as spamming, is that what you are saying?

I am asking since spacebar made this script add the module name as the first keyword before adding the "real" kaywords from the article...

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux 2.4.28 - Linux srv60 2.6.12.6 / Apache / 4.0.22 - 4.1.22 - 5.0.22 -5.0.32 / 4.3.11 - 4.4.2 - 4.4.4 - 5.2.5 / 9.0.6.1 - 9.1.2.1 - 9.2.0.RC2


Even if those words were not somewhere on the page, a couple of words hardly qualifies as keyword spam. The penalties are applied for people where there is obvious keyword stuffing totally unrelated to content.

I think spacebar's hack is quite clever and meritorious.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):


Phoenix wrote

I think spacebar's hack is quite clever and meritorious.


I agree on that one!
I would love to see something like this for other modules as well, like forums, coppermine etc if done right. Smile

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux 2.4.28 - Linux srv60 2.6.12.6 / Apache / 4.0.22 - 4.1.22 - 5.0.22 -5.0.32 / 4.3.11 - 4.4.2 - 4.4.4 - 5.2.5 / 9.0.6.1 - 9.1.2.1 - 9.2.0.RC2


I'm getting really good and relevant google ads in my site since I implemented this hack.

I put this type of hack into my news and poetry modules and I'm now getting really good and relevant google ads and various web search types of hits now.

I'd say its a successful exercise.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Unix / 2.0.46 (Red Hat) / 0.9.7a / 4.1.9-standard / 4.3.2 / 9.0.6.1


Excellent good to know.

J.
j e r u v y a t y a h o o d o t c o m

Need help? Look here: www.dragonflycms.org/W...d=112.html
Need to chat? Look for me on irc.freenode.net

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Ubuntu7.10/Debian3.1 - 2.2.3/1.3.37 - 5.0.38/4.0.27 - 5.2.1/4.4.7 - CVS/9.1.2}


I like this but I dont now where to put it I think its article.php in the news module am I correct please let me know before I kill my site.

Richard Hart
CMS Version 9.2.1
PHP Version 5.2.8
MySQL Version 4.1.22-max-log (client: 5.0.45)

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CMS Version 9.2.1/PHP Version 5.2.8/MySQL Version 4.1.22-max-log (client: 5.0.45)

All times are UTC


Jump to: