Page descriptions

Started by nend, August 26, 2009, 01:39:32 PM

Previous topic - Next topic

nend

<meta name="description" content="'.$context['page_title'].'" /> should not be the page description. There should be a common varible to be set to state page descriptions instead of using $context['page_title'];.

In my site I created $context['page_description']. I will explain how I set it up.

In the forum index page it sets the page description to the page title.
In a category it sets the page description to the category description.
In a topic it sets the page description to the very first post in a topic.

Before the page description is displayed, it has to go through formatting. I take out all bbc, line breaks, extra spaces, html and all other illegal characters. I also check to see if the page description is too long and take off the ending.

Real simple to implement and I believe it is necessary to have this as a part of SMF's core.

Keywords on the other hand isn't too important to me at this time. I believe keywords should state the content of a entire site so SMF is ok with this at this time.

But if you want to, I haven't tried to implement this myself but keywords can probably be set per index and topic via the control panel. Keywords for post however can be pulled from a post. First off you would have to take off common words and that would leave the keywords.

However, a array with common words is probably just a waste. Loading on every page load and bogging down the loading time just a bit.

Just some of my opinions, I would really like to see $context['page_description'] in future releases though. Not for me, but other users.  ;)

Arantor

Most search engines do not normally consider this much now.

How did you implement it then, if it's simple to implement? How and where is $context['page_description'] built?
Holder of controversial views, all of which my own.


nend

Some of the links in your post were not found or match more than one topic or member.
Please use the id instead.

    * "/!]*?[^[": not found.


I'm not posting any links, why can't I post the code. SMF is missing up on me  :'(

nend

In Display.php find.

// Censor the title...
censorText($topicinfo['subject']);
$context['page_title'] = $topicinfo['subject'];


Add after

$context['page_description'] = strip_tags($topicinfo['body']);

nend

In MessageIndex.php find.

// 'Print' the header and board info.
$context['page_title'] = strip_tags($board_info['name']);


Add After

$context['page_description'] = strip_tags($board_info['description']);

nend

In index.template.php find

// The main sub template above the content.
function template_main_above()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

if($context['page_title']=='' && isset($_GET['action']))
$context['page_title']=$context['forum_name'].' - '.$_GET['action'];
elseif($context['page_title']=='' && !isset($_GET['action']))
$context['page_title']=$context['forum_name'];



nend

Add after.

if (!isset($context['page_description'])) {
$context['page_description'] = $context['page_title'];}
else
{$context['page_description'] = strip_tags($context['page_description'], '<br>');
$context['page_description'] = str_replace('"', "'", $context['page_description']);
$context['page_description'] = str_replace("<br />", " ", $context['page_description']);
$context['page_description'] = str_replace("&quot;", " ", $context['page_description']);
$context['page_description'] = str_replace("'", " ", $context['page_description']);
$context['page_description'] = str_replace("/n", " ", $context['page_description']);
$context['page_description'] = str_replace("/r", " ", $context['page_description']);
$context['page_description'] = str_replace("/t", " ", $context['page_description']);
$context['page_description'] = str_replace("  ", " ", $context['page_description']);
$context['page_description'] =  preg_replace('A bug in smf 2.0 will not let me post this section of the code, Woot a buggy.', '', $context['page_description']);
$context['page_description'] = html_entity_decode ($context['page_description']);}


Then in the meta information change the description tag.

<meta name="description" content="', $context['page_description'], '" />

Please note though I am using SMF 1.1.10. And yes these descriptions are important still. I don't know about the other search engines but I know Google still looks at this tag. Sometimes Google will decide to use this tag or it will use other content from the page. But it sort of gives a directive of what the description ought to be and if it is a good description, Google will use it. I know this because Google is currently using most of my descriptions instead of looking for one in the source.

nend

Check this out.
http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=lEW&q=site%3Awww.sicomm.us%2Fsiforum%2Findex.php%3Ftopic%3D95.0&aq=f&oq=&aqi=
In my source
<meta name="description" content="SI Sitemap generator crawls your website for links to generate sitemaps. It saves these links in data files during the crawl to later phase the data and turn it into a XML sitemap.

Again.
http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=site%3Awww.sicomm.us+New+Theme&aq=f&oq=&aqi=
In my source
<meta name="description" content="Ok, I couldn t wait until this theme was finished to put it up on the site. It is a simpler theme which I believe is allot better. Changes will happen every so often so don t mind the style changes." />


If that wasn't enough evidence, look no where in the page is the "Ok, I couldn t". Notice my code removed the ' from couldn't. If you read the post it says "Ok, I couldn't".
http://www.sicomm.us/siforum/index.php?topic=146.0

Not to be rude here, but I am just trying to prove a point that yes the description tag is still very important.  ;)

And yes I know that towards the end of my script in the template, it is crude, I just haven't cleaned it up yet, but it works somewhat.  :D

nend

Sorry about posting my code in multiple post, a bug in SMF 2.0 RC1.2 was preventing me to post the entire code at once. But in this post I found a bug. Where do I report bugs, I can't post it on the board because it will not let me post it.

nend

Lets try spacing it.

This code just take out the extra spaces.

| [ [ \ / \ ! ] * ? [ ^ \ [ \ ] ] * ? ] | s i

Belongs in the '' Where I typed a buggy.

   $context['page_description'] =  preg_replace('A bug in smf 2.0 will not let me post this section of the code, Woot a buggy.', '', $context['page_description']);

Arantor

That's not a bug in 2.0. This forum has a mod that utilises wiki-style links for things, meaning that a double bracket does have other meanings.

Interesting code and while I can see its use, there is enough evidence to suggest that you actually risk being penalised for duplicate content.
Holder of controversial views, all of which my own.


nend

I know what you are saying.

You got two duplicate links that you know your going to have for one post
index.php?topic=1.msg1
index.php?topic=1.msg1#new


And then you got this
index.php?topic=1.msg3#msg3

All the messages in the post. The only problem though is that all of them are going to have the same description with how it is set up now.

The only way to do this is to get the msg value and add its content to the description. Probally cut off the description on both ends.

User replied, blah blah blah blah, In topic, blah blah blah

Not hard to do.  :D


Arantor

Actually your first example doesn't count. No search engine should be considering anchor links separately to the primary link destination, since ultimately 1.msg1 and 1.msg1#new produce the same content. The difference is purely in the browser.

If the description is the same as the page content, how do you know whether Google is using the description or the page content to form your description?

And actually the 'bug' you refer to isn't a core SMF bug. It's a bug specifically referring to the usage of double [ symbols due to the wiki-style links mod available.
Holder of controversial views, all of which my own.


nend

QuoteActually your first example doesn't count. No search engine should be considering anchor links separately to the primary link destination, since ultimately 1.msg1 and 1.msg1#new produce the same content. The difference is purely in the browser.

Your right about that, just have to worry about 1.msg1 and so forth.

QuoteIf the description is the same as the page content, how do you know whether Google is using the description or the page content to form your description?

Simple I provided the example above
QuoteAgain.
http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=site%3Awww.sicomm.us+New+Theme&aq=f&oq=&aqi=
In my source<meta name="description" content="Ok, I couldn t wait until this theme was finished to put it up on the site. It is a simpler theme which I believe is allot better. Changes will happen every so often so don t mind the style changes." />
If that wasn't enough evidence, look no where in the page is the "Ok, I couldn t". Notice my code removed the ' from couldn't. If you read the post it says "Ok, I couldn't".
http://www.sicomm.us/siforum/index.php?topic=146.0
QuoteAnd actually the 'bug' you refer to isn't a core SMF bug. It's a bug specifically referring to the usage of double [ symbols due to the wiki-style links mod available.
Yeah, I found that out earlier today.  ;)

I think this is a great feature, If you don't want to incorporate it, it is fine with me.  ;D

Just to let you know I reset up my site a couple months ago after about a year being offline. I have 426 links from Yahoo and 320 indexed links from Google. A Alexa rating of 398,285 for 3 months and a one week average of 205,574 with a change of 766,918 for 3 months.

According to Google Webmaster Tools I have at least 20 search queries which are in the top 10 or 20 of the search results. If you go to my page you will see that is about all the content I have.

I don't know, could it be SEO  :-\

But your right about one thing, I have to make sure the descriptions are not duplicates. Webmaster tools reports 5 duplicate descriptions. It isn't hurting my site that bad, but if I fix it my search results will be that much better.  :D



Arantor

I'm not a dev, I'm really just a newbie to many things, what do I know?

But the duplicate content was always going to be an issue, and Google does not always consider meta description; it just has the option of using it. On most of the sites I've worked on, it's just taken from the main content even when the meta description was populated and relevant.
Holder of controversial views, all of which my own.


nend

#15
That is Google, "hmm, is this description good enough or do I have to take one from a page."

Just as long as the descriptions are good enough, you will almost always have a good chance of Google using your description.  ;)

http://googlewebmastercentral.blogspot.com/2007/09/improve-snippets-with-meta-description.html

I just finished up with some coding today, a couple minutes, don't have time to do anything anymore. O'Well, at least all my pages have a little different meta descriptions for each page instead of exactly the same.  :D

I was banging my head over here, I was like wtf, why can't I load up the information for the topic. I was missing with Display.php for a while until I opened QueryString.php. Somebody slammed $_REQUEST['topic'] on the ground and stomped on it.  >:(

Doh, I'm going to have to set up a new $var to run through. Somebody just sent $_REQUEST['topic'] through the grinder. Real funny stomping it before it gets to Display.php.  :'(

j_jindal1

This is something I was looking for.... I modified the files as suggested but still when I'm at post, the description tag doesn't show the post contents. I get this for all posts....

<meta name="description" content="" />

Can you please suggest what might have gone wrong. The link to my site is www.just4dosti.com

As per your desc, the following is not working for me..

Quote from: nend
In a topic it sets the page description to the very first post in a topic.
www.ShayarFamily.com Shayri forum of Friends

Something like that

Quote from: Arantor on August 27, 2009, 11:09:14 PM
But the duplicate content was always going to be an issue, and Google does not always consider meta description; it just has the option of using it. On most of the sites I've worked on, it's just taken from the main content even when the meta description was populated and relevant.

I believe there is support for canonical URL's in SMF 2.0 now. That's a tag in the HTML headers that tells search engines the main place content should be located at, so sites are no longer penalized for having the same content at multiple URL's, if the canonical URL tag points to the same place.

I've also written a site where Google pulls the description straight from the description tag. It works wonderfully in the search results.

The question would be how to best grab an appropriate snippet for pages. It's something worth looking into adding for 2.1.

nend

Nice find there

I just implemented this on my site.

You can compare the theme link tree url to the current url in the browser, if they don't match you can echo the canonical url. Since the linktree always has the exact url to topics without any other var or anchor in it.  ;)

sevamaster

Hi there,
It does not work in SMF 2.0 RC3.
Could anybody give an idea to force it working in SMF 2.0 RC3?

Advertisement: