Adding your META tags on to a drupal page

Printer-friendly versionSend to friend

Most blogging systems OR CMSes don't have the option to add the META KEYWORDS and META DESCRIPTION tags which are the key to search engine success to some extent.

Yes, I know you can add them in theme files... but if you change theme ? You have to re-add them. So we need a persistent solution which doesn't change while changing themes.

Below is a simple procedure where you can add your META tags to a drupal (taking 5.x here) system (without editing any of the theme files!).

Open common.inc in your favourite editor. common.inc is found in <drupal-install-path>/includes

Scroll down to Line Number 116 (or search for drupal_get_html_head).

After the first function line, you will see a line like this -

 
$output = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";

You then append these lines RIGHT AFTER the above line (else its not going to work).


$output .= '<meta name="keywords" content="keywrd1,keywrd2,..." />'."\n";

$output .= '<meta name="description" content="A small description here" />'."\n";

Save the file. Make a backup of the older file and place this new common.inc overriding the old one.

The above method has been tested and was found to work. So, if you have any problems just comment down here!

Have a nice day!


Nilesh Govindrajan

Site & Server Administrator
iTech7

Comments

Why the hell would you do

Why the hell would you do this? This is the worst advice I have seen.

This just make life very hard when you want to upgrade. The whole point of themes is that they are separate from the core files so you can upgrade easily and copy across the theme to the new version as soon as they come out.

Are you changing themes that often?

If you want a good solution for adding meta tags just use th nodewords module: http://drupal.org/project/nodewords

Well I was compelled to write

Well I was compelled to write this tutorial because at the time of the installation of this site, the nodewords wasn't available for 6.x and I seriously wanted to add meta tags to the page.


Nilesh Govindrajan

Site & Server Administrator
iTech7

Thanks, very useful. Shopping

SUPER

thanks
SUPER !

thanks! I'm going to do the

thanks!
I'm going to do the same for my sites

Agree to #1. Do not hack

Agree to #1. Do not hack core! This tutorial will do more harm than good to the readers.

This tut is a bit advanced

This tut is a bit advanced one, so you should not mess up with core unless you know PHP very well.


Nilesh Govindrajan

Site & Server Administrator
iTech7

Syndicate content