Recent Topics

1 Jun 19, 2009 17:25    

This is not a bug, but it is related to CVS release so I thiught this was the proper place to post it. Fell free to move it somewhere else if appropriate.

Currently tag & category pages don't get any meta description tag. This is kind of a problem for search engines, in particular it seems google doesn't like pages without propoer meta description tags.

http://www.google.com/search?hl=en&rlz=1B3GGGL_esDE280DE280&q=site%3Aliberal-venezolano.net+inurl%3Aetiquetas%2F&aq=f&oq=&aqi=

As you can see in the URL above all my tag pages have the same snippet displayed by google. Not nice, since they have different kinds of information.

I have modified the function skin_description_tag() in inc/skins/ so that tags and category pages hava a meta description which includes the tag/category name and the page number in case there are multiple pages with the same tag/category.

This is how the new skin_description_tag() function looks like:

/**
 * Template tag
 */
function skin_description_tag()
{
	global $Blog, $disp, $MainList, $disp_detail, $tag, $paged, $Chapter;

	$r = '';

  //pre_dump($disp_detail);
	if( is_default_page() && !empty($Blog) )
	{	// Description for the blog:
		$r = $Blog->get('shortdesc');
	}
	elseif( $Blog->get_setting( 'categories_meta_description') && ( $disp_detail == 'posts-cat' ) )
	{
		$r = $Chapter->get( 'description' );
    if( $paged > 1 ) {
      $r .= sprintf(T_(' - Page: %d'), $paged ) ;
    }
	}
	elseif( $Blog->get_setting( 'excerpts_meta_description' ) && in_array( $disp, array( 'single','page') ) )
	{	// Excerpt for the current single post:
		$Item = & $MainList->get_by_idx( 0 );
		$r = preg_replace( '|[\r\n]+|', '', $Item->get('excerpt') );
  }
  elseif( $disp_detail == 'posts-tag' ) 
  {
    $r = sprintf(T_('%s: Here you can find all posts tagged «%s»'), $Blog->get('name'), $tag) ;
    if( $paged > 1 ) {
      $r .= sprintf(T_(' - Page: %d'), $paged ) ;
    }
  }
  elseif( $disp_detail == 'posts-cat' )
  {
    $r = sprintf(T_('%s: Here you can find all posts in the category «%s»'), $Blog->get('name'), $Chapter->get('name')) ;
    if( $paged > 1 ) {
      $r .= sprintf(T_(' - Page: %d'), $paged ) ;
    }
  }

	if( !empty($r) )
	{
		echo '<meta name="description" content="'.format_to_output( $r, 'htmlattr' )."\" />\n";
	}
}

What it does is: we check if we are displaying a tags page and if so, we add a little descriptive text to the meta tag. If we are in second, third, etc. page for the same tag, we say so also. Google doesn't like repeated meta description tags either. The same goes for categories which don't have a description defined or when we don't have enabled "categories_meta_description".

The diff would be this:

@@ -532,22 +495,31 @@
  */
 function skin_description_tag()
 {
-       global $Blog, $disp, $disp_detail, $MainList, $Chapter;
+       global $Blog, $disp, $MainList, $disp_detail, $tag, $paged, $Chapter;
 
        $r = '';
 
+  //pre_dump($disp_detail);
        if( is_default_page() && !empty($Blog) )
        {       // Description for the blog:
                $r = $Blog->get('shortdesc');
        }
-       elseif( $Blog->get_setting( 'categories_meta_description') && ( $disp_detail == 'posts-cat' ) )
-       {
-               $r = $Chapter->get( 'description' );
-       }
        elseif( $Blog->get_setting( 'excerpts_meta_description' ) && in_array( $disp, array( 'single','page') ) )
        {       // Excerpt for the current single post:
                $Item = & $MainList->get_by_idx( 0 );
                $r = preg_replace( '|[\r\n]+|', '', $Item->get('excerpt') );
+  } elseif( $disp_detail == 'posts-tag' ) {
+    $r = sprintf(T_('%s: Here you can find all posts tagged &laquo;%s&raquo;'), $Blog->get('name'), $tag) ;
+    if( $paged > 1 ) {
+      $r .= sprintf(T_(' - Page: %d'), $paged ) ;
+    }
+  }
+  elseif( $disp_detail == 'posts-cat' )
+  {
+    $r = sprintf(T_('%s: Here you can find all posts in the category &laquo;%s&raquo;'), $Blog->get('name'), $Chapter->get('name')) ;
+    if( $paged > 1 ) {
+      $r .= sprintf(T_(' - Page: %d'), $paged ) ;
+    }
        }
 
        if( !empty($r) )

2 Jun 19, 2009 17:44

Hi Austriaco,

Currently leeturner and Walter are working on this issue. If you want to join the comversation please pop by at irc://irc.freenode.net#B2evolution
Thanks for reporting.

Good luck


Form is loading...