Tag Archives: Google

SEO for Magento

Magento is a great e-commerce CMS, with tons of incredible possibilities.

Most of time, we would prefer simplier e-commerce scripts than Magento, because Magento needs a lot of ressources to run, and it’s made for gigantic online shops, else it could be hard to take advantage of all its performance.

I’ll have many occasions to talk about Magento later on; I’m starting a e-commerce project. The goal of this article is to give a useful link. When you’re running a e-commerce, SEO is interesting you even more : here is a great Magento SEO guide, that looks not too complex. Some people say Magento is not SEO-friendly, but you can do pretty well with this article!

URL Rewriting with EasyPHP and Apache2

URL Rewriting allows a dynamic website to have clean and relevant URL addresses.

In the next article, we’ll see what is URL rewriting for, and how to put it in function on your local apache server.


Why to rewrite URLs?

Normally, a URL address of a dynamic website would look like this :


http://blog5643.com/index.php?section=1&cat=5&article=12&p=2

But if we give the server a rewriting rule, it may look like this instead :


http://blog5643.com/1-Technologie/5-Web/12-Comment-faire-son-propre-blog/page-2

That’s much cleaner, and easier to understand for the user and for Google. are a good way to improve SEO; moreover, Google doesn’t like that much URLs that have more than two parameters into its query string (like in the first example).

How to set up URL Rewriting on my local apache server?

If you wish to use URL rewriting « at home », you will probably need to activate the rewriting module (called mod_rewrite) of Apache. It is not very complex to do, but if you don’t know how, it may be frustrating.

Then, here are solutions to set up URL Rewriting on your local server, using EasyPHP or Apache 2. Note that if you use MAMP or MAMP PRO, mod_rewrite is already enabled.

The only difference between the activation of mod_rewrite for EasyPHP 1.8 and for EasyPHP 2, is that in the version 2, there’s only a line to uncomment.

Activation of mod_rewrite on EasyPHP 2

Uncomment this line (remove #) in EasyPHP’s configuration, httpd.conf (Menu e/Configuration/Apache in EasyPHP) :


LoadModule rewrite_module modules/mod_rewrite.so

Then, in the same configuration file, look for the <Directory> tag, relevant to your website. It should look like this :



#
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all


You see « AllowOverride None »? Change it for « AllowOverride All ». This little trick will say to the server to pay attention to the .htaccess file. Without this modification, the .htaccess will be ignored by the server.

Activation of mod_rewrite on EasyPHP 1.8

Uncomment the two following lines (remove #) in EasyPHP’s configuration, httpd.conf (Menu e/Configuration/Apache in EasyPHP) :


LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

In the same file, look for :


#
# This may also be “None”, “All”, or any combination of “Indexes”,
# “Includes”, “FollowSymLinks”, “ExecCGI”, or “MultiViews”.
#
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
#
Options Indexes FollowSymLinks Includes

#
# This controls which options the .htaccess files in directories can
# override. Can also be “All”, or any combination of “Options”, “FileInfo”,
# “AuthConfig”, and “Limit”
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

Take care that AllowOverride All is set to ALL and not set to NONE.

In EasyPHP 1.8, it’s already set to ALL, but in EasyPHP 2.0, you must do it by hand. Be aware that if it’s not set to ALL, the .htaccess file won’t be considered by the apache server, it’s very important (and very simple)!

Activation of mod_rewrite on Apache 2 (dedicated server)

It’s very easy to do. Run the console (for Macs, it’s called Terminal, and it’s located in System applications) and type this :


a2enmod rewrite

Then, you must edit Apache’s configuration, for that it doesn’t ignore the .htaccess file. Open configuration file :


sudo nano /etc/apache2/apache2.conf

Find the tag <Directory> that is for your website, then search for AllowOverride None, and set it to AllowOverride All.


/etc/apache2/sites-enabled/

A default file may be there, in that case, its name would be 000-default.

Once you saved your changes, restart the server :


/etc/init.d/apache2 reload

How can I verify if URL Rewriting is really activated

Check if mod_rewrite is there and activated

Very simple. Type :

phpinfo();

in a PHP file, then check that « mod_write » is there. If it’s not there, there’s something wrong. Of course, it means that rewriting doesn’t work. Take a look to  previous steps again, you may have missed something.

Create your .htaccess file (the name of the file starts with a dot), and place it at the root of your site.

How to name a .htaccess file correctly, with its dot

With Windows, it may cause a problem because this syntax is for hidden files (normally). It is possible to create the .htaccess file by using Notepad. Save your file this way : ".htaccess" (yes, with quotes).

You can also rename it in DOS, if you saved it in text format :


ren htaccess.txt .htacces

Rewriting rules in .htaccess file

Insert these lines in the .htaccess file :

Options +FollowSymlinks
RewriteEngine on

# ————————————————————————-
# > URL REWRITING TEST
# ————————————————————————-

RewriteRule ^try.html$ page_test.html [NC,L]

Create a file named page_test.html, also at the root of the website, with .htaccess.

Now that the rewriting rule is there, try to open essai.html in your browser.

  1. If you get page_test.html : URL rewriting is working!
  2. If you get an 404 error because of page_test.html : It works but page_test.html doesn’t exist.
  3. If you get an 404 error bacuse of try.html, and mod_rewrite is there when you try phpinfo() : Your rewriting doesn’t work! Are you sure you did all right?
  4. If you get an 500 error, and you are on local server : Your .htaccess file contains errors in its rewriting rules (but your rewriting is working, you must only have a look on your code and fix what’s wrong).

How to rank a website

Website Ranking is a step that becomes more and more important during the creation processus of a website.

Here is a list, ordered by importance, of factors that can influence your ranking. You must not forget anything from this list.

These are points not to forget when you create a websites. For a lot bigger list, I would recommend you to visit SeoMoz – Google Search Engine Ranking Factors.

Keywords in the <TITLE> tag

First, use different <title> tags on every page. Choose well which keywords will be in the title; your <title> tag should be a summary of the main subject of the page. A common way to do this is to include the subject of the page, and then, the name of the website. For instance :


MP3 players, stereo – Electronics shop

Number of backlinks to your website, and popularity of them

More there are websites that have links to your website, more your site is popular to Google. More these websites are popular, more you’ll become popular. Be aware not to abuse; if you create thousands of backlinks for a brand new website in one shot, Google may notice it and put you deep into the sandbox, or blacklist you.

To subscribe to good quality directories, and look for partnership without having a break are needed efforts to put your website on the map. For directories subscriptions, 5 to 10 per week is a good rate. If you have a RSS feed, you should also submit your website to RSS directories.

Keywords in the page itself

You must write your contents using the keywords you want to rank. Here, the keyword density is pretty important (the % for presence of the keyword in the whole page). For instance :


The Electronics shop is selling many MP3 player brands : Ipod, Samsung, Sandisk, etc.

You can help you to choose the right MP3 player for you, because we know MP3 players pretty weel!


It is important not to abuse; we must not be able to notice that you tried to put your keywords everywhere. It must be present a couple of times in your page, if you wish use it for your Google ranking.

Keywords in <h1> tag

Heading <h1> is something like the title of your page, like the <title> tag. Moreover, it is common to use the same information in the  <title> tag that in <h1>.

Keywords in the domain name

Importance of keywords in a domain name is often a debate, but we could say it remains to be an important factor. If I own the domain name electronics-shop.com, it may help for keywords « electronics shop ». The URL would be bolded in Google results someone would search those keywords.

Keywords in page URL

You must pay attention to names of PHP and HTML files, or better :use URL Rewriting. For instance :

http://www.electronics-shop.com/ipod-nano-16gb.php

is much better than :

http://www.electronics-shop.com/produits.php?tag=343&id=9&order=0&search=ipodnano8gb

Note that Google don’t like to see too much parameters in an URL, like it the second part of the example.

Keywords in headings <h2>, <h3>, etc.

These headings may be interpreted in a way as much important as <h1> tag. Try not to repete in <h2> what was already in <h1> or <title>. The goal of those headings is to show a hierarchy of content. Use it correctly, and if it doesn’t give anything more to the content organisation, don’t use it at all.

Keywords in DESCRIPTION meta tag

You must use a different DESCRIPTION meta on every page, containing well chosen keywords. Think of the DESCRIPTION meta tag as being a description of your <title> tag, because both will appear, most of time, in Google results page.

Valid and correct use of HTML language

HTML isn’t very complex, but lots of people don’t use it coherently. Google likes clean HTML, well scripted and W3C valid.

That’s it, it was only a little preview of facts you must think about, when you create a website. You should also submit a Google Sitemap, and be sure to use valid XHTML.

Google Analytics, online statistics

Google Analytics is a free service of Google, which allows you to learn a lot of important information about visitors of your website. If you don’t know it yet, you must get into it as soon as possible!

To know the amount of visitors that come on your website, their origin, where they go and when, is an essential element for the success of your website. To study the behavior of your visitors will help you to improve your website (especially its ergonomy), or at least, to understand what are the problems linked to the user experience your website offers. If you can’t use a more specialised statistic service, I think that Google Analytics would be a very good beginning.

How to add Google Analytics to your website?

Go on Google Analytics‘s website, and suscribe to Google’s online services. If you already own a Gmail account, you may use it for it.

Once you suscribed, click Access Analytics, then Sign up ».

Fill up the form, answer the questions it asks.

Then, Google gives you a javascript code to insert into your HTML pages. You must insert it into ALL your pages, else you won’t get real statistics. With a source editor (Dreamweaver, Golive, etc.), or Notepad, insert the code, just before the closing of the </body> tag (at the end). If you insert it higher in your HTML code, it may slow down your page loading.

The javascript code Google gives you looks like this (don’t use this code, use the one Google gives you) :




After this, you must give Google at least a couple of hours before it starts recording statistics from your website.

Let it go during a couple of days, and then, go back to see what happened. Statistics of a day is accessible only after midnight the same day.

Here is a little trick : In your content stats, you can see what are the pages your visitor go on. It would help you a lot if you would use URL Rewriting for your pages, because it’s a lot easier to recognize which ones are those pages than if they are URLs with many parameters that have no meaning for you.

Now you have to explore Google Analytics as you wish; there are lots of possibilities, only a personal experience of this tool will help you to understand better all its functions.

Create a Google Sitemap for your website

A Google Sitemap is a very important element for ranking of your website : it is used to tell Google which pages it must include in his engine. It also helps your new pages to be ranked quicker, and to be sure that all your relevant content is indexed.

A Sitemap, it’s basically a map of your website (I hope you already guessed it); a tree of pages in which the level of importance of certain pages over some other pages is cleary visible.

Of course, it’s not mandatory to create a Sitemap for your website, its purpose is especially to help Google (then also yourself). It is possible that not all the pages you included in your Sitemap will be added in Google. Even if you show him the way, Google isn’t dumb, it will only rank pages that are really relevant.

This means that you should give up for contact pages, help pages, or any other page that is not relevant. Rather than this, try to rank your « best » pages, those that have content of quality.

Depending on how your website is build (static website or dynamic website), the way to build your sitemap may vary. This article will show you some common ways to do it.

At any time, you should refer to the Google documentation about Sitemaps.

Create a static Sitemap

When I say static, I mean a Sitemap you have make yourself, line by line, and that won’t update itself automatically. That’s what we normally use for websites that only have static contents, pure HTML.

To do this, don’t waste your time in writing it yourself, you can rather use an automatic Sitemap generator. You can also use it for a dynamic website that doesn’t rewrite URLs, but you will have to generate it everytime you want to update it (usally, often) – this is something you’ll forget to do, for sure.

Create a dynamic Sitemap

A dynamic Sitemap will update itself automatically, which is useful if you update your website on a regular basis. The method given here is using URL Rewriting to make it more clean and simple.

First, create a .htaccess file, located at the root, or modify the .htaccess file you may already have :


Options +FollowSymlinks
RewriteEngine on

# Link for the Sitemap
RewriteRule ^sitemap\.xml$ /sitemap.php [L,NC]

This way, sitemap.php will allow us to automatically generate the content of the XML file (the real Sitemap). Each time Google will try to open sitemap.xml, sitemap.php will be executed and will make an update of the XML « file ».

Create a file named sitemap.php. In the example bellow, we get the content of articles of an imaginary blog.

The structure of the table used in the example bellow :


CREATE TABLE IF NOT EXISTS `blog` (
`id` mediumint(9) NOT NULL COMMENT ‘ID of the article’,
`texte` text NOT NULL COMMENT ‘Text of the article’,
`date` date NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=’Articles of blog’;

The content of the file sitemap.php :

// MySQL Connection$host = “localhost”;
// normally, it’s localhost
$user = “USERNAME”;
$pass = “PASSWORD”;
$bdd = “NOM_OF_THE_DB”;

@mysql_connect($host,$user,$pass) or die(“Unable to connect : “.mysql_error());
@mysql_select_db(“$bdd”) or die(“Unable to select dabatase : “.mysql_error());

// Indicate file type : XML document
header(“Content-Type: text/xml”);

// MySQL query to get articles of the blog
$requete = “SELECT id, date FROM blog ORDER BY date DESC”;
$resultat = mysql_query($requete);

// Writing of the XML file
// Headers :
$sm = ”;
$sm .= ‘xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://www.google.com/schemas/sitemap/0.84
http://www.google.com/schemas/sitemap/0.84/sitemap.xsd”>’;

// Articles of the blog
while ($blog=mysql_fetch_array($resultat,MYSQL_ASSOC)) {
$sm .= ‘‘;
$sm .= ‘http://yoursite.com/blog?id=’.$blog[‘id’].’‘; // you may adapt the URL syntax to your need, this is an example
$sm .= ‘‘.$blog[‘date’].’‘;
$sm .= ‘monthly‘;
$sm .= ‘0.7‘;
$sm .= ‘
‘;
}

$sm .= ”;

echo $sm;

As you may guess, the Sitemap schema is working on this structure :






<loc> Location of the page. Don’t forget to write the domain (http://www.domain.com).
<lastmod> When was the page updated the last time (or when was it created). This data is normally recorded in your database by your scripts. You must give this value with a W3C valid format.
<changefreq> What is the frequency of updates for this page? (always, hourly, daily, weekly, monthly, yearly, never). This is only to help Google, Google may not respect this indication. This is useless to set always if you do not plan to update a page once it is created.
<priority>

Priority is a way for Google to know which pages are more important than some others in your website. This comparison doesn’t apply to other websites. It is useless to put 1 everywhere, you won’t help yourself. Give a higher priority to pages that seem more important and that updates often.

If everything is well working, you should be able to see your Sitemap if you try to reach the page sitemap.xml. Check if it is valid, and then submit it to Google.

Bien sûr, il est possible d’améliorer ce script de plusieurs façons. Par exemple, vous pouvez stocker dans vos tables de données, dans une colonne priority, la priorité à donner à chacune des pages. Même chose pour le changefreq.

Of course, it’s possible to upgrade this script in many ways. For instance, you also could store your pages priorities in an additional column. Same thing for changefreq.

It’s of course a lot less complicated with CMS.

Create a dynamic Sitemap for Joomla!

For Joomla!, you have 2 major choices of components :  xMap and Joomap, both available for J!1.0x et J!1.5x versions.

Je n’ai pas essayé Joomap, mais xMap fonctionne très bien. Il existe des extensions pour la plupart des composants connus (Sobi2, Adsmanager, Community Builder, …), ce qui est indispensable. Il s’agit des deux plus connus, mais il existe d’autres composants.

I didn’t try Joomap, but xMap works fine. There are extensions for most of the popular components (Sobi2, Adsmanager, Community Builder, …), which is very important. xMap and Joomap are the most known components, but there are other components you may want to try.

Create a dynamic Sitemap for Drupal

Install the XML Sitemap module for Drupal, disponible pour Drupal 5.x.

Créer un sitemap dynamique pour WordPress

Download the plugin of Arne Brachhold, which works fine. If you are interested into SEO, I invite you to read my article about SEO Ranking with WordPress.