Recent Topics

1 Nov 17, 2005 10:21    

What is SEO Keywords & Description Hack?
[list]SEO Keywords & Description Hack is a two-functions hack intended to help search engines to better index your posts.[/list:u]

What does this hack do?
[list]SEO Keywords & Description Hack is a two-functions hack makes possible to add post-specific (X)HTML page description and keywords list. If no post-specific information is given, the default blog-specific information is used instead.[/list:u]

How to use this hack?
[list]To add a post-specific description, add the following tag into your post's (X)HTML source code:

<!--description My nice post-specific description.-->

Other tags are also supported for your convenience (including meta_description, see source code for details).

To add a post-specific keywords list, add the following tag with comma-separated keywords and expressions into your post's (X)HTML source code:

<!--keywords keyword1,keyword2 keyword3,keyword4,etc.-->

Other tags are also supported for your convenience (including meta_keywords, see source code for details).[/list:u]

What are this hack's limitations?
[list]This hack lacks a user-friendly GUI.[/list:u]

What b2evolution versions are supported?
[list]The following implementation supports most [url=http://b2evolution.net]b2evolution[/url] versions, including 0.9.0.x (Europe, Berlin, Oslo, Madrid, Copenhagen, Paris, Amsterdam), 0.9.1 (Dawn) and should still be compatible with the yet to be release 0.9.2 (Phoenix) release without any change.[/list:u]

Implementation
[list]If you haven't created one before, create an empty conf/hacks.php and and edit it with the following code:

<?php 

?>

All the additional code should be copied between the above tags.

Edit your conf/hacks.php file and add the following lines at the end of it:

/**
 * SEO Keywords & Description Hack v0.1
 * Display blog- or post-specific meta descriptiocontents.
 *
 * @copyright (c)2005 by kwa (@link http://blog.lesperlesduchat.com/dev.php)
 */
function HackDispMetaDescriptionContents()
{
	global $Blog, $disp, $p, $preview, $title;

	if( $disp == 'single' )
	{
		// Single post display
		// Display post-specific description (this hack-specific behavior)

		if( !empty($p) )
			$Item = Item_get_by_ID( $p );	// TODO: use cache
		else
			$Item = Item_get_by_title( $title );	// TODO: use cache

		if( preg_match( '/<!--(meta_?)?(short_?)?desc(ription)?[\s]+([^>]*)[\s]*--\>/si', $Item->content, $Matches ) )
		{
			// Found post-specific description, display it
			echo( $Matches[ 4 ] );
		}
		else
		{
			// Not found description, display blog-specific (generic) description
			$Blog->disp( 'shortdesc', 'htmlattr' );
		}
	}
	else
	{
		// NOT single post display
		// Display blog-specific description (default b2evolution behavior)
		$Blog->disp( 'shortdesc', 'htmlattr' );
	}
} // HackDispMetaDescriptionContents()

/**
 * SEO Keywords & Description Hack v0.1
 * Display blog- or post-specific meta keywords contents.
 *
 * @copyright (c)2005 by kwa (@link http://blog.lesperlesduchat.com/dev.php)
 */
function HackDispMetaKeywordsContents()
{
	global $Blog, $disp, $p, $preview, $title;

	if( $disp == 'single' )
	{
		// Single post display
		// Display post-specific keywords this hack-specific behavior)

		if( !empty($p) )
			$Item = Item_get_by_ID( $p );	// TODO: use cache
		else
			$Item = Item_get_by_title( $title );	// TODO: use cache

		if( preg_match( '/<!--(meta_?)?keywords[\s]+([^>]*)[\s]*--\>/si', $Item->content, $Matches ) )
		{
			// Found post-specific keywords
			// Display them
			echo( $Matches[ 2 ] );
		}
		else
		{
			// Not found post-specific keywords
			// Display blog-specific (generic) description
			$Blog->disp( 'keywords', 'htmlattr' );
		}
	}
	else
	{
		// NOT single post display
		// Display blog-specific keywords (default b2evolution behavior)
		$Blog->disp( 'keywords', 'htmlattr' );
	}
} // HackDispMetaKeywordsContents()


Then, edit your favorite skin and change the following code near the beginning of your skins/favorite_skin/_main.php file:

<meta name="description" content="<?php $Blog->disp( 'shortdesc', 'htmlattr' ); ?>" />
<meta name="keywords" content="<?php $Blog->disp( 'keywords', 'htmlattr' ); ?>" />

by the following code:

<meta name="description" content="<?php HackDispMetaDescriptionContents(); ?>" />
<meta name="keywords" content="<?php HackDispMetaKeywordsContents(); ?>" />

Your hack is ready to be used![/list:u]

What future improvements are envisaged?
[list][list]

  • A user-friendly GUI is probably the most important thing to do. That should be done as a Toolbar plugin.[*]A warning message in preview mode would be interesting when those tags are missing. That can be done as a Rendering plugin.[/list:u][/list:u]

  • Where can I find related plugins and hacks?
    [list][list]

  • [url=http://forums.b2evolution.net/viewtopic.php?t=4466]Code to generate 'Google Sitemaps'[/url]

  • [url=http://forums.b2evolution.net/viewtopic.php?t=4476]Google sitemap[/url][*][url=http://forums.b2evolution.net/viewtopic.php?t=4595]Another Google Sitemap Generator for b2evo[/url]

  • [*][url=http://forums.b2evolution.net/viewtopic.php?t=4459]Search Engines Optimization (SEO)[/url][/list:u][/list:u]

    2 Nov 21, 2005 23:47

    How about something like this for the toolbar, in /plugins/toolbars/_quicktags.toolbar.php, which would add a new button labeled 'SEO'?

    This example drops both blocks into the post at once with no need for a closing tag.

    
    		b2evoButtons[b2evoButtons.length] = new b2evoButton('b2evo_seo'
    																							,'SEO'
    																							,'<!--description REPLACE THIS WITH YOUR POST DESCRIPTION--><!--keywords KEYWORD1,KEYWORD2 KEYWORD3,KEYWORD4,etc.-->',''
    																							,'k'
    																							,'<?php echo T_('SEO Desc and Keywords [ALT-K]') ?>'
    																							);
    

    There have always been line-wrapping issues with script blocks in the _quicktags.toolbar.php file, especially when copying a sample block from a forum post, so the best/safest option might be to just open the file and copy an existing block to maintain the line-wraps in your particular editor, then replace the content of your copied block with the info from this one... Maybe?

    Anyway, this block should just dump the pre-formatted starting and ending tags into the post when you press the 'SEO' button, and then you replace the CAPITAL text with your own description and keywords.

    I guess separate buttons could be made for the description 'DESC' and for keywords 'KEYW'... This example drops the opening section of the block into the post, you make your edits, then you hit the button again to close the tag block. It creates a separate button for "description" and for "keywords".

    
    		b2evoButtons[b2evoButtons.length] = new b2evoButton('b2evo_desc'
    																							,'DESC'
    																							,'<!--description REPLACE THIS WITH YOUR POST DESCRIPTION','-->'
    																							,'W'
    																							,'<?php echo T_('SEO Description Includer [ALT-W]') ?>'
    																							);
    
    
    		b2evoButtons[b2evoButtons.length] = new b2evoButton('b2evo_keyw'
    																							,'KEYW'
    																							,'<!--keywords KEYWORD1,KEYWORD2 KEYWORD3,KEYWORD4,etc.','-->'
    																							,'k'
    																							,'<?php echo T_('SEO Keywords Includer [ALT-K]') ?>'
    																							);
    

    but some of us have already cluttered their admin toolbar buttons with other custom stuff and space can become an issue after a while so the single-button option might be desirable.

    jj.

    3 Nov 25, 2005 09:00

    jibberjab wrote:

    How about something like this for the toolbar, in /plugins/toolbars/_quicktags.toolbar.php, which would add a new button labeled 'SEO'?

    That's an idea. I must say since I implemented [url=http://www.fckeditor.net/]FCKeditor[/url] as posts' text editor, I removed the Quick Tags toolbar...

    4 Nov 25, 2005 09:10

    According to my site's [url=http://www.xiti.com]Xiti[/url] traffic analysis, my blog's traffic coming from search engines increased by 80 to 110% since before implementing this hack.

    Figures from 11/24/2005 compared to those from 11/17 (the day I implemented the hack on my site):

    • Direct access: +55.3% ("natural" increase);[*]Search engine: +106.4%;[*]External links: 9.7% ("natural" referrers).[/list:u]

    • Search engines appear to use a page's:
        [*]URL;[*]title;[*]description meta tag;[*]keyword meta tag[/list:u]to increase the weight of the associated keywords appearing in the web page in their indexing algorithms. Since each post has its own keywords, it appears to be far better to associate post-specific description and keywords as in the current hack than a global, blog-specific one as in a default [url=http://b2evolution.net]b2evolution[/url] version.

    5 Manuel Jan 13, 2006 19:03

    Manuel

    Hi all and thanks for the hack. Fabolous.
    It's important to format the output, otherwise it's not xhtml-valid anymore when using " for example.

    Just modify the 'echo' parts like this:

    // Found post-specific description, display it 
    echo( format_to_output( $Matches[ 4 ], 'htmlattr' ) );


    And:

    // Found post-specific keywords 
    // Display them 
    echo( format_to_output( $Matches[ 2 ], 'htmlattr' ) );

    This is a core function provided by b2evo and used everywhere in the system.
    Works fine at [url=http://www.manuel-breitfeld.de]my playground[/url]. ;)

    6 Manuel Jan 13, 2006 22:15

    Manuel

    I have now added a button in the backend to call a file which generates the meta-tags "description"/"keys" and then appends them with <!--description/keywords --> automatically to the textfield.

    Some word's aren't keywords, so I have a blacklist. This blacklist is called keywords_bad.txt and is currently filled with german words. So if you're english, please feel free to create your own list with words. They have to be separated by a line break.

    /* -------------------------------------------------------------------- */
    /* :: Important :: */
    /* -------------------------------------------------------------------- */

    You have to use the "SEO Keywords & Description Hack" by kwa.
    Otherwise b2evo won't be able to create meta-sags, so the meta-tag
    generator would be useless.
    Please do install the hack - it's easy!
    Get it: http://forums.b2evolution.net/viewtopic.php?t=6129

    /* -------------------------------------------------------------------- */
    /* :: Installation :: */
    /* -------------------------------------------------------------------- */

    1. Unpack [url=http://www.manuel-breitfeld.de/media/metatag_generator_b2evolution.zip]this zip-file[/url] and copy the folder named
    'metataggenerator' into the following directory:
    plugins/

    So afterwards it should look like that on your server:
    plugins/metataggenerator/
    - keywords_bad.txt
    - metatag_generator.php
    - readme_deutsch.txt
    - readme_english.txt

    2. Brwose to directory 'admin/' and open the file _edit_form.php.
    Please do make a backup of this file before!

    On line 195 you have the following code:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    if( $current_User->check_perm( 'upload' ) )
    	{ // ------------------------------- UPLOAD ---------------------------------- ?>
    		<input type="button" value="<?php echo T_('Upload a file/image') ?>"
    		onclick="launchupload();" tabindex="12"  />
    		<?php 
    	}
    	
    	
    	?>
    	</div>

    Replace that by this one:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    if( $current_User->check_perm( 'upload' ) )
    	{ // ------------------------------- UPLOAD ---------------------------------- ?>
    		<input type="button" value="<?php echo T_('Upload a file/image') ?>"
    		onclick="launchupload();" tabindex="12"  />
    		<?php 
    	}
    	?>
    	
    	<input type="button" class="button" value="Generate meta-tags" onclick="window.open('<?php
    	echo $baseurl . '/' . $plugins_subdir . '/metataggenerator/metatag_generator.php?integrated';
    	?>', 'MetaTagGen', 'width=10, height=10'); self.focus();" name="MetaTagGen" />
    	
    	</div>



    Now save the file and this "installation" is finshed. ;)

    /* -------------------------------------------------------------------- */
    /* :: How to work with :: */
    /* -------------------------------------------------------------------- */

    1. When editing or writing a post you can now find a new button beside
    Save/Preview called "Generate meta-tags".
    By pressing the button, the script will automatically append the meta-
    tags with <!-- --> into the textfield.

    2. Useless words such as "you", "and", "me", "than" have nothing to do
    with keywords. So we have to kill them.
    All words which sould be ignored when generating the keywords-list
    can be added to the list keywords_bad.txt.
    Please feel free to do so!

    Download the archive including all needed files:
    http://www.manuel-breitfeld.de/media/metatag_generator_b2evolution.zip

    The archive contains a english and german readme file. Germans can also look up [url=http://www.manuel-breitfeld.de/home.php/2006/01/13/meta_tag_generator_fur_b2evolution]the post in my personal blog[/url].

    7 Feb 08, 2006 23:24

    kwa wrote:

    What is SEO Keywords & Description Hack?

    Implementation

      If you haven't created one before, create an empty conf/hacks.php and and edit it with the following code:
      <?php 
      
      ?>
      All the additional code should be copied between the above tags. Edit your conf/hacks.php file and add the following lines at the end of it: [/quote] I already have a conf/hacks.php file. I'm not sure what it does. Is there another way to implement this? J

    8 HOLOTTA.COM Apr 08, 2006 23:55

    HOLOTTA.COM

    had evers on line 63...When I added the meta codes it took me to a blank page...please help

    9 Apr 13, 2006 00:27

    guchuj05 wrote:

    kwa wrote:

    All the additional code should be copied between the above tags.

    I already have a conf/hacks.php file. I'm not sure what it does. Is there another way to implement this?

    There is no other "official" way to implement the hack otherwise than following the above instructions.

    Since you have a conf/hacks.php, guess what you have to do? Follow the above instructions! And what are they? I'm going to repeat them again:kwa wrote:

    All the additional code should be copied between the above tags.

    What does that mean? That means this hack's code has to be copied somewhere between the beginning PHP tag:

    <?php

    and the ending one:

    ?>

    That means you can insert the hack's code just after the beginning tag:

    <?php

    or just before the ending one:

    ?>

    If you don't know PHP at all, dont try to put it anywhere else.

    10 Apr 13, 2006 00:29

    HOLOTTA.COM wrote:

    had evers on line 63...When I added the meta codes it took me to a blank page...please help

    Remove the meta codes and follow the right instructions again. If you mistype the meta codes, you're going to have a blank page again. In fact, do not type anything, use your browser's copy feature and your HTML source code editor's paste feature.

    11 Jul 15, 2006 05:29

    I love this hack, and it worked great on my blog when it was on 0.9.2, but now when I try to carry it over into 1.8, permalink pages come up blank.

    Maybe there are just some variables with different names now? Any chance someone could post an updated version?

    12 Aug 27, 2006 14:11

    I'd love to see an upgrade for B2 Evo 1.8 of this plugin, too!

    13 Oct 04, 2006 15:58

    I fooled around a bit with the source but couldnt get the hack working with 1.8.2 :(

    So kwa, please update your code ! ,-)

    Manuel already updated his metatag generator to run with 1.8.2 but this only works with the seo hack....

    Thx a lot !

    Cheers,
    Joshua

    15 Oct 10, 2006 20:53

    Any chance I can get the manuel hack? Its a 404 not found and I dont use 1.8

    16 Dec 03, 2006 09:49

    @mikkyT:
    As all mails I sent you were dropped by your mailserver I just post the zip with the metatag generator here. Hope someone will find this useful ,-)

    There are serveral changes to be done to get it running with version 1.8.x, I will write a little tutorial but first have to find Manuels mails in which he describes the changes.

    19 Mar 10, 2007 00:07

    How to use this hack?

      To add a post-specific description, add the following tag into your post's (X)HTML source code:
      <!--description My nice post-specific description.-->
      Other tags are also supported for your convenience (including meta_description, see source code for details). I installed/implemented the hack but I have quite a trouble with figuring out on how to "add the following tag into your post's (X)HTML source code". How do I get to see or display or access the post's (X)HTML source code? Where is it in the admin? Please help as I am stuck on this for more than 2 hours now. Thanks a lot, Stanof

    20 Mar 11, 2007 03:04

    any chance some one could show how to apply this hack to 1.9.2?

    I gave it a good try, but was stuck on the get_item_by_id and get_by_title functions in the hack.php

    Please?

    21 Mar 11, 2007 14:28

    There used to be a plugin on the thread I linked, but I appear to have removed the file. When I get a moment I'll re-attach it

    ¥

    22 Mar 12, 2007 03:20

    that would be great -- thanks! I am alternatively playing with adapting the technorati plugin...

    23 Mar 12, 2007 17:39

    Hi ¥åßßå,

    you seem like a guy that knows a lot about this plug in.
    I have a question in the thread above but here is the short version of it:

    I installed/implemented the hack but I have quite a trouble with figuring out on how to add the keywords code tag into my post's (X)HTML source code.

    How do I get to see or display or access the post's (X)HTML source code?
    Where is it in the admin?

    The guy that created this topic talks about how to instal it and what to type into the (X)HTML source code of your post. But I can't figure out how to display/alter the post's HTML code.
    How do you getting displayed in the admin?

    Thanks a lot,

    Stanof

    24 Mar 12, 2007 18:03

    This is a renderer type hack/plugin wich means you type one thing and it gets changed to XHTML. In this case kwa describes you should type into your post

    <!--description

    here comes your description

    -->


    so by starting with "<!--description" the renderer will know what's going on and will change the part after that.

    XHTML is not visible in the backoffice. Just create your post and view the source of the blog afterwards.

    25 Mar 12, 2007 20:44

    Thanks a lot man, but I tried that and it didn't get parsed. I view the source of the post page I created and nothing there. I see exactly what I typed in in the blog's admin.

    May it be that the plug in is no installed correctly then?
    Is that why it's not parsing?

    Thanks,

    Stanof

    26 Mar 13, 2007 00:15

    Try the link mentioned before http://forums.b2evolution.net/viewtopic.php?t=9349&highlight= with more information. I am not sure wether the plugin works for 1.8.x and upwards. I have 1.9.2 and didn't get it to work so I'll wait till further notice from the developers.

    General plugin knowledge: yes, you shuold unzip any plugin. With the newer pulgin you copy the complete folder to the ../blogs/plugins/ folder. With older plugins there will not be a folder but one or two files. These go in the same ../blogs/plugins/ folder.
    In the backoffice a sucessfully copied plugin will show up under tools ->plugins. Some plugins need or want additional setup or toggle on/off. There should be a manual type of file accompanying the plugin.

    Good luck

    29 Jul 02, 2009 14:14

    Thanks for sharing SEO Keywords & Description and how to hack them

    30 Jul 03, 2009 16:02

    3.3 now has fields for meta description and meta tags for each post.


    Form is loading...