10 Drupal best practices for creating a solid website

Submitted by ravisagar on Tue, 10/07/2014 - 20:55

Learning Drupal is not difficult at all. You can learn to create a decent website in Drupal in few months only but when your site grows both in terms of content and functionality then you need to make sure that the site performance is not hampered and also it should be easy to maintain it.

There are lot of mistakes that new Drupal developers do when they create big Drupal sites. Today we will highlight some of the things to keep in mind for creating and maintain a Drupal site.

1. Understand the Requirements
Before diving into the full fledged development, always read the requirement specifications in detail. Clear any doubts you may have with your manager or client. There should not be any assumptions about the functionality. You should know what content type you are going to create in the project, how many views need to there, what is the layout of the site, how many fields need to be created, whether the site is responsive or not.

2. Use Version Control
As you work with your files that are under version control, each change is tracked automatically. This can include modifying a file, deleting a directory, adding a new file, moving files or just about anything else that might alter the state of the file. Instead of recording each change individually, the version control system will wait for you to submit your changes as a single collection of actions. In version control, this collection of actions is known as a commit. There are numerous benefits of using version control for managing your code. Multiple people can work on the functionality and contribute. The changes are done in orderly fashion if you are using a version control. It is easy to roll back to old version if something is not working as expected as you always have the history of what you did.

3. Use same development environment - Vagrant
Everyone has their own preferences when it comes to the choice of operating system and also the tools that they use. When you build a website for a client you need to make sure that it will work on production, which is a specific flavor of linux running specific version of apache, php and mysql. Whereas the developer who worked on the site could be using Mac. The person responsible for testing could be running windows. It is always a pain to fix issues that are platform specific and it is not a wise choice to enforce same platform. For that reason it is a good idea to use Vagrant it is basically a tool for managing Virtual machines. It really enabled developers to work on their favorite machine at the same time using the same environment for development like everyone else in the team. You can give Vagrant a try on their website.

4. Use separate database server
Running a big Drupal site could consume lot of resources on the server. Since Drupal store all the configurations along with the content in the database and running a MySQL server on the same machine could be an overkill. For this reason it is recommended that you use a separate server for database. Of course keep in mind the latency issues.

5. File Management
Store the images, files in separate folders under files folder. For example if there is image field in content type "blog" then specify the storage location as blog when adding the image field. So wherever an image is uploaded in the blog it will be stored in files/blog/ directory. This really make easy to manage the images on the site. If you are using Image Style then Drupal will create lot of sub directories for storing images of different styles.

6. Try to re-use existing modules
If you come from a PHP background then you might be tempted to write PHP snippets for achieving various little functionalities, a good Drupal developer will always try to reuse and configure existing contributed modules. Not every contributed module is great, you should always check how actively that module is being developed, and you can also check the issues for that module to check for any major bug in it.

7. Don't use too many Modules
When we said re-use existing modules for a feature that someone already developed, it doesn't mean that you download too many modules. It really affects the performance of the site and it might not be easy to update those contributed modules. An experienced Drupal developer will always try to implement the functionality using few modules.

8. Staging Environment
We can not emphasis more on this. Always have a staging server which is identical to your production and always test the site completely on staging. This will ensure that any platform specific issues are resolved and you will not get surprises when you launch the site.

9. Use Issue Tracker Tool
When you start working on the project, you will surely have some plan. If there are multiple people working on the project with each having their own responsibilities then it becomes more important to make sure that every is doing the tasks assigned to them and for project manager it is more important to keep track of the progress. For the same reason we recommend that you use some issue tracking tool like JIRA for managing work project. It will really help everyone to have clear visibility on the target and current status of the project.

10. Prepare your Server Architecture
The choice of server in terms of configuration, memory, bandwidth is really important aspect for a successful site. You may have a great site with amazing functionality but if your server is not able to run the Drupal site fast then the user will not get good experience browsing it and you might loose return traffic. If you are looking for a shared host then I can recommend Webfaction, which is in my opinion one of the best shared host for small to medium sites but if you are building a complex site with expected traffic of over 10000 visitors per day then it would be wise to choose linode, which is not very costly. Of course for using both webfaction and linode you need to have decent knowledge of linux.

I hope these points will help you to plan your next great Drupal project. Have fun.