A bit of SEO in Drupal

where is my utopia

Well, we have already installed our new Drupal site and after getting into matter we can take a look and see how we can prepare our brand new site to help search engines knowing which is the content of our site (that's indeed what is called SEO).

Some things search engines like are maps of your site (sitemap) clean urls (as we did here, our site is prepared for clean urls but this does not mean our nice - node/x - urls are very clean and meaningful).

Let's go step by step:

Sitemaps:

A sitemap is a file in which we say which pages are there on our site and which indexation priority they have, it's a XML file that can be done manually, but that's not clever doing so. One of the best features of Drupal is it's modular by design, so the best thing we can do is searching for a module that can do what we want to do before trying to burn our head trying to reinvent the wheel.

In this case, we can install Simple Sitemap, it's a little nice module that meets our requeriments without big hassle.

To install a module there are several ways to do so, composer is the recommended one but that's quite steep for new users so in this first case we will be using the plain old manual download and install tactic, you can do so from the web frontend but this needs your apache to have writing permission on modules directory and that's not a nice idea, so we can ssh into our server and:

cd /var/www/drupal/modules/
wget https://ftp.drupal.org/files/projects/simple_sitemap-8.x-2.7.tar.gz
tar -zxvf simple_sitemap-8.x-2.7.tar.gz
rm simple_sitemap-8.x-2.7.tar.gz
more simple_sitemap/README.md
<-- just in case it's nice to read a file that asks you to read it

Once we have done it we can go to web frontend (a

point your browser to /admin/modules) and activate the module - it will be shown in group SEO -  if you can not see the module, make sure your apache can read the directory and you have not changed the admin theme, some themes can have issues in the admin if they are not prepared for admin so I always recommend keeping Seven as admin theme.

Once it is installed we can go to "/admin/config/search/simplesitemap" and generate a new sitemap, but it won't generate a crap, to start generating something we need to check which entities we want to include in our new sitemap and the priority given to it.

Once we have chosen which kind of content we want to index (we can do the same with taxonomy terms), we will see them generated on our sitemap.

Clean URLs:

Everytime you write a new article, unless you manually change it, it will be available at a URL with the form "node/n", those URLs are clean because they do not include variables but they are meaningless, we want URLs that are meaningful and this can be achived with a great module, useful and very well done Pathauto, this module allows you to generate clean URLs with patterns created with the tokens you choose, this module has two dependencies, so we must not only install Pathauto, but also Token and CTools, so let's go:

cd /var/www/drupal/modules/
wget https://ftp.drupal.org/files/projects/token-8.x-1.0-beta2.tar.gz
tar -zxvf token-8.x-1.0-beta2.tar.gz
rm token-8.x-1.0-beta2.tar.gz
wget https://ftp.drupal.org/files/projects/ctools-8.x-3.0-alpha27.tar.gz
tar -zxvf ctools-8.x-3.0-alpha27.tar.gz
rm ctools-8.x-3.0-alpha27.tar.gz
wget https://ftp.drupal.org/files/projects/pathauto-8.x-1.0-beta1.tar.gz
tar -zxvf pathauto-8.x-1.0-beta1.tar.gz
rm pathauto-8.x-1.0-beta1.tar.gz

Once all modules are downloaded we can go to admin section and activate them in order. Once it's activated, we just have to go to its configuration page admin/config/search/path/ and create the patters we want to use, in my particular case I have done something easy:

Patrones de pathauto

Once it's done, the URL of newly created nodes will be changed by their title and taxonomy terms by their name.

We can use Bulk generate to generate new clean URL for all existing nodes, after doing so we can regenerate our sitemap and we now have a full sitemap with clean and meaningful URLs.