Drupal site setup

Installation, configuration and optimization of a site using Drupal 7

List of modules used:

Core modules to disable

Core modules to enable

Contributed modules

For multilingual sites consider installing also the following modules:

Themes

Configuring the site

File system path

Set file system path for public and private files Configuration > (Media) File system

Drupal cron

Disable Drupal standard cron (poormanscron) in Configuration > Cron

Setup a cronjob if server allows (using wget or drush)

Languages (for multilingual sites)

Remove the language prefix (www.example.com/en) for the default language:

Configuration > (Regional and language) Languages > Detection and selection

Edit the default language and set "Path prefix language code" to an empty string

Configuration > Regional and language > Multilingual settings > Strings

Select the "Translatable text formats" according to your needs.

Disabling user registration if not needed

Configuration > (People) Account settings

Change Registration and cancellation > Who can register accounts to "Administrators only"

Activate revisions by default for all the content types

Administration > Structure > Content types > [Edit content type]

In the Publishing options tab check "Create new revision"

Do this for all content types

Image styles

Increase the quality of the images: set jpeg quality to 85%

Administration > Configuration > Media : Image tookit > JPEG quality

Configuring the modules

ckeditor

Add this javascript code to profiles advanced options to prevent ckeditor from removing css classes

Configuration > Content authoring : CKEditor > Edit profile > Advanced options > Custom javascript configuration

config.allowedContent = true;

You may also remove some plugins if you find them not useful and enable browser's native spell checker

config.removePlugins = 'scayt,menubutton';
config.disableNativeSpellChecker = false;

Some other useful configuration values:

config.autoParagraph = false;
config.ignoreEmptyParagraph = false;

A configuration file can be created in theme's folder ckeditor.config.js to add some useful configuration directives

This example is preventing the removal of the empty span and i tags

CKEDITOR.dtd.$removeEmpty.span = 0;
CKEDITOR.dtd.$removeEmpty.i = 0;
CKEDITOR.dtd.$removeEmpty.a = 0;
CKEDITOR.dtd.$removeEmpty.p = 0;
CKEDITOR.dtd.$removeEmpty.div = 0;

Starting with ckeditor module 7.x-1.14 CKEditor library may be installed in a custom location instead of module's folder (where it gets removed by automatic updates)

Edit ckeditor global settings and change "Path to CKEditor". This path is going to use libraries folder:

%l/ckeditor

path auto

Configuration > Search and metadata > URL aliases > Patterns

Set "Default path patterns" to [node:title] instead of [node:title] | [site:name]

(there is no need for the site name to be appended to the title tag for each page)

Drupal creates a page for every taxonomy term but these pages are not always needed.

When taxonomy term pages are not used we should set a custom path for these pages and prevent them from indexing (and maybe also from access) with .htaccess rules

Set "Default path pattern (applies to all vocabularies with blank patterns below)" to

restricted/[term:vocabulary]/[term:name]

And in robots.txt add the following rule:

Disallow: /restricted/

If module transliteration is active in setting tab check also

"Transliterate prior to creating alias"

This will help pathauto to generate from the title "Dernières actualités" a link dernieres-actualites instead of dernières-actualités or dernires-actualits

meta tag

Configuration > (Search and Metadata) Meta Tags

Edit and/or override default settings (for global and other types of pages):

Also remove meta variables that are part of Drupal core

Put this code in template.php

/**
 * Unset meta variable in the header that are part of the core.
 */
function myTheme_html_head_alter(&$head_elements) {

    // remove meta generator tag
    unset($head_elements['system_meta_generator']);

    $remove = array('shortlink', 'canonical');
    foreach ($head_elements as $key => $element) {
        if (isset($element['#attributes']['rel']) && in_array($element['#attributes']['rel'], $remove)) {
            unset($head_elements[$key]);
        }
    }
}

Set meta tags for views pages

Activate Meta Tags: Context module

backup and migrate

Configuration > (System) Backup and Migrate > Schedules

Set up a scheduled backup at least once a day and also the number of backup files to keep (otherwise the backup folder will grow too much in size over time)

Site speed optimization

Reducing the number of requests

(files that are retrieved from the server after the html file is downloaded and parsed)

Reducing the number of css and javascript files

See here how to reduce the number of CSS and javascript files

Reducing the number of images

This can be accomplished by using css sprites techniques when the theme is created

Performance settings

On this page

Administration menu > Configuration > Performance

Check "Cache page for anonymous users" and "Cache blocks"

Set Minimum cache lifetime to a value depending on the frequency of the site updates (maximum for sites rarely updated)

Leave "Expiration of cache pages" to <none>

Check "Aggregate and compress CSS files." and "Aggregate JavaScript files"

Apache mod expires and .htaccess configuration

Drupal has a default configuration in the default .htaccess file if Apache expires module is active

The default configuration allows browsers to cache resources (images, files etc) for 2 weeks

Enable page compression (Apache mod_deflate)

Add these lines to .htaccess to enable the compression only for text files

Apache module mod_deflate needs to be enabled

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
    # Exclude browsers with known problems
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>