SEO – Do It Youselfer (DIY)

Everyone needs a SEO, either a SEO plugin or a DIY SEO.

Plugins are good but you don’t know if they are indeed performing to your expectation. As the plugin gets more and more “advanced”, things get more and more complicated. With so many parameters/variables to worry about, sometimes you need a manual to make sure if you have done right or wrong.

If you are using a plugin, check page source to see if the plugin is indeed doing what you want.

Or you could manually add the following codes to your header.php file.

<title>
<?php if ( is_home() ) { ?><?php bloginfo(‘name’); ?><?php } ?>
<?php if ( is_search() ) { ?>Search Results&nbsp;|&nbsp;<?php bloginfo(‘name’); ?><?php } ?>
<?php if ( is_author() ) { ?>Author Archives&nbsp;|&nbsp;<?php bloginfo(‘name’); ?><?php } ?>
<?php if ( is_single() ) { ?><?php wp_title(”); ?>&nbsp;|&nbsp;<?php bloginfo(‘name’); ?><?php } ?>
<?php if ( is_page() ) { ?><?php wp_title(”); ?>&nbsp;|&nbsp;<?php bloginfo(‘name’); ?><?php } ?>
<?php if ( is_category() ) { ?><?php single_cat_title(); ?>&nbsp;|&nbsp;<?php bloginfo(‘name’); ?><?php } ?>
<?php if ( is_month() ) { ?><?php the_time(‘F’); ?>&nbsp;|&nbsp;<?php bloginfo(‘name’); ?><?php } ?>
<?php if (function_exists(‘is_tag’)) { if ( is_tag() ) { ?><?php bloginfo(‘name’); ?>&nbsp;|&nbsp;Tag Archive&nbsp;|&nbsp;<?php single_tag_title(“”, true); } } ?>
</title>
<?php
if (is_home() || is_front_page() ) :
echo ‘<meta name=”description” content=”‘.get_bloginfo(‘description’).'” />’;
else :
$post = $wp_query->post;
$descrip = strip_tags($post->post_content);
$descrip_more = ”;
if (strlen($descrip) > 155) {
$descrip = substr($descrip,0,155);
$descrip_more = ‘ …’;
}
$descrip = str_replace(‘”‘, ”, $descrip);
$descrip = str_replace(“‘”, ”, $descrip);
$descripwords = preg_split(‘/[\n\r\t ]+/’, $descrip, -1, PREG_SPLIT_NO_EMPTY);
array_pop($descripwords);
$descrip = implode(‘ ‘, $descripwords) . $descrip_more;
echo ‘<meta name=”description” content=”‘.$descrip.'” />’;
endif;
?>
<?php global $post;
if( is_single() || is_page() || is_home() ) :
$tags = get_the_tags($post->ID);
if($tags) :
foreach($tags as $tag) :
$sep = (empty($keywords)) ? ” : ‘, ‘;
$keywords .= $sep . $tag->name;
endforeach;
?>
<meta name=”keywords” content=”<?php echo $keywords; ?>” />
<?php
endif;
endif;
?>
<?php if ( !(is_home()) && !(is_single()) ) { ?><meta name=”robots” content=”noindex,follow” /><?php }?>
<?php if ( is_singular() ) { ?> <link rel=”canonical” href=”<?php the_permalink(); ?>” /> <?php } ?>

 

What we get from the codes?

1.Title: different titles for different types of pages/posts.

2. Meta Description: use excerpt as meta description for pages/posts; Front/Home use site description as meta description.

3. Meta Keywords: use tags as keywords; Front/Home page use the last post’s tags as keywords.

4. Tell robot not to index only home/front page and single post pages. Author, archive, search, tag pages will be excluded.

5. Add canonical URL to eliminate content duplication problem.

6. You should have a faster loading website!

———————-
sources:
http://www.92app.com/replace-all-in-one-seo-plugin.html
http://wordpress.org/support/topic/create-excerpt-for-meta-description
http://wordpress.org/support/topic/add-tags-to-meta-keywords