Drupal best practices: site-building in Drupal 8

Drupal best practices: site-building in Drupal 8

Introduction

This is the first article from the series of content on Drupal development best practices. We will start with site-building.

Any developer who has been working in web for a long time has come across sites with one or several following problems:

  1. SEO - search engines don’t display your site at the top positions
  2. Security - special tools often show that your site has been infected with malicious code
  3. Maintenance - it takes a lot of time to add new features, fix old bugs, etc
  4. Performance - sites are very slow and many users leave it without waiting until the page loads.

It happens because your site was built without using proven methods (aka the best practices). This article will show your problems and how to solve them. We deliberately didn’t make separate lists for each problem mentioned since one module sometimes solves a few problems.

List of not recommended Drupal modules

This is a list of modules that you have to disable on a live website. They are not bad, you just must use them only on the dev environment.

  1. Devel - it can help you debug problems in Twig templates or generate dummy content, but all these features are needed only for developing websites.
  2. UI submodules - all submodules like Views UI, Field UI, etc. should be disabled. You need to use them on a dev instance and then migrate necessary configurations.

In most cases, you will not need these modules, too:

  1. Color
  2. Dashboard
  3. Overlay
  4. Shortcut
  5. Toolbar

The main goal of these lists is to try to avoid too many modules. Too many enabled modules can slow down your site. Additionally, modules that are poorly maintained and contain bugs can be detrimental to the security and stability of your site.

List of recommended Drupal modules

We strongly advise using the following modules. Having them installed,  you will be able to solve many of your problems.

  1. Update manager - it’s a very helpful module that can inform you about any security updates for your modules and the Drupal core.
  2. Advanced CSS/JS Aggregation - improves the front-end performance of your site.
  3. Backup and migrate - keeps copies of your site in case of serious problems with it.
  4. Elysia Cron - extends Drupal standard cron, allowing a fine-grain control over each task.
  5. Redirect - allows a site administrator to add 301 redirects for old page URLs.
  6. Rabbit Hole - hides unpublic nodes.
  7. Security Kit - reduces the risks of exploitation of different web application vulnerabilities.

Make Drupal more friendly for editors

Drupal 8 provides inline editing and working preview. Also, it moved the “advanced” options to the right sidebar. The admin pages became more clear, but editor experience is not ideal yet. It depends on you whether it will be easy to work with a site or not.

  1. You should use as many content types as reasonable. If you create a lot of content types, maintaining your website will also take much time.
  2. Display only needed settings. You have permission to configure what editors will see. Do not make them deal with a lot of unnecessary settings.
  3. Editors must have the ability to edit content and layouts. It means that content should never be stored in code. Also, there are a lot of modules to build layouts (Panels, Display Suite, Paragraphs, Layout Suite, etc). Just use them and give permissions for editors to update layouts too.
  4. Simple site navigation is needed not only by users but for your editors too. Contextual links, breadcrumbs, admin menu - this is not a complete list of what will facilitate their work.
  5. Try to remember an important rule: only nodes should store content, not taxonomy nor entities. They were created for other purposes (i.e. for categorizing contents).
  6. Let your developers using HTML tags. Editors should work with content. That’s why you need to install CKEditor.
  7. Working with images and other kinds of media must be also clear. You can use Entity Browser, Entity Embed modules (just look at this great documentation).

Additional recommendations

  1. SEO - we have already written about this. Please have a look at our article Drupal and SEO.
  2. Distributions - using the ready-made solutions saves your time (try to find a similar project here before creating a new website)
  3. Drupal theming best practices

Conclusion

All these practices are based on many years of experience of many developers. Just follow them and you can save your time and avoid common mistakes. Hope it will help!

You might also like