Robert Roose - Drupal web designer
By Robert Roose

What is a multisite?

When I say multisite I'm talking about a website which consist of one single codebase and database, but has the functionality to virtually create multiple websites. So a visitor can access these sites via different domain names, but in reality they are all served from the same source. 

An example would be a company having a corporate website and a separate website where they post jobs opening within the company. Both sites have their own domain name, and if needed their own look and feel.

Multisite vs multidomain 

When you want to create multiple websites from one codebase with Drupal you have two options:

  1. Traditional multisite functionality: This is where the codebase (files for the core, modules and themes) is shared but each site has their own database. Having a multisite solution like this can be useful when you have multiple websites that have different needs. Think of modules or a specific configuration. Because the database is not shared every website has their own content, users and functionality. 
  2. Multiple websites with the Domain Access module: With the Domain Access module it is possible to create different domains within your Drupal website. Each domain can be accessed via it's own URL. In this case the database is shared, making it possible to share content and users between the sites. Also, if you create new functionality such as a new paragraph type or a search API view, all sites can profit from these improvements.

I prefer the second option because sharing content, users and improvements between the websites is one of the things that makes a multisite solution great. So when I'm talking about a multisite, I'm talking about a multisite solution with Domain Access. 

If you want to know more about the difference between the two options check out this Multi-site vs. Multi-domain comparison by One Shoe.

Why would you want a multisite solution?

If you're tasked with maintaining multiple websites, which are more or less the same when it comes to functionality, than a multisite is the way to go.

The advantages are:

  • Reducing cost. You only have to maintain one codebase. Updating of fixing bugs in the multisite will automatically transfer to all other sites.
  • Easily share content, media and users between the multiple sites.

The disadvantage being that when one of the sites produces a bug, this will possibly be the case for all your sites. Also when the database is shared it means that if one site is hacked, they all are. That's why it's important to keep your Drupal code up to date and always  install security updates as quickly as possible. 

How does creating a multisite setup with Drupal work?

For now I won't do an in depth tutorial, but I want to give you a global impression on what steps you have to take to create a multisite with Drupal.

  1. Install the Domain Access module.
  2. Create one or multiple domain records.
  3. Each domain record can have it's own domain name (or URL). For example the corporate website can be located at www.company.com while the specific jobs site can have www.jobsatcompany.com. It's also possible to work with subdomains such as jobs.company.com.
  4. You can now create content (nodes) or users and assign them to one or multiple domains.

A practical example of how you can use the multisite functionality of Drupal

Let's say you have a multisite set up with a dedicated domain for a corporate website and an additional domain for job offerings. Both websites need a overview of latest news. Here is how to achieve this with Drupal and Domain Access:

  1. You create a 'News' page and assign it to both domains. 
  2. Include a menu item to this page in the main menu. Because the 'News' page is assigned to both the corporate as the jobs site, the menu item will be visible on both sites.
  3. Create a block with views displaying all news items. Within this view you can filter news items by active domain. 
  4. Publish this block to the 'News' page created in step 2.
  5. Create some news items and assign them to either the corporate or the jobs site.

Depending on the domain or site you are viewing this newly created 'News' page will only show items assigned to this domain. This way you can share functionality like a news overview page between multiple sites. You only have to create the view once. In this example it's also possible to publish a news item to both domains. This will ensure the item is available on the news page for both sites.

As you can see using Drupal and Domain Access to create a multisite can save you a lot of time.

Reusing a theme for multiple sites

Another cool thing of using a multisite solution with Drupal and Domain Access is that you can easily reuse a theme. So you can use the same theme for your corporate and jobs website. Both sites will benefit from every improvement you make to this theme.

You can also use totally different theme for a specific domain or site. But what's even better is that you can create subtheme. Say, for example, you want your corporate website to have a header with a red background, but you want the header of your jobs website to have a blue background. In this case you can create a subtheme for your jobs website and you only have to overwrite the CSS rule that specifies the background colour of the header. If you make a change in the main theme, this will be also visible on the subtheme except for the CSS rules that are overwritten. Giving you the benefit of having to maintain one theme, but still enough freedom to adjust where necessary for other sites.

Downside of creating a multisite with Drupal

When you choose to create a multisite solution with Drupal and Domain Access there is one big downside. And that's the compatibility of modules. In some case you want to share functionality between sites, but the both need their own values. If a module is not compatible with Domain Access it won't be possible to enter specific values for individual domains. 

A real life example I've encountered is trying to create an XML sitemap for multiple domains.

An XML sitemap is an XML document containing links to all the pages (or nodes) on your website. The URL of this XML sitemap can be sent to search engines, such as Google. They will be notified when a new link has appeared in the sitemap making it easier for search engines to crawl your website. Thus making your pages appear faster in the search results.

There are two modules available which can create an XML sitemap for your Drupal website. But in both cases I could not make them work like I wanted them to. Ultimately I've created separate RSS Feeds containing all the content of the different sites filtered by domain which are also accepted by services such as the Google Search Console.

Save time and money by easily creating multiple websites

A multisite solution built with Drupal and Domain Access has a lot of advantages. You can easily create a new website and share content and users between the different domains. You only have to keep one Drupal installation up to date. But make sure you do, because if your Drupal is insecure, all your sites are vulnerable. It's also possible to share functionality between the sites saving time recreating it in every different Drupal setup. The biggest downside is the compatibility of third party modules. This can force you to be creative in search for a solution or have to do without desired functionality.

Do you have any questions about building your multisite with Drupal? Let me know by leaving a comment below.

P.S: If you want to receive updates on more of my Drupal blog posts you can subscribe to my Drupal newsletter.

The content of this field is kept private and will not be shown publicly.