The Beta Site module's core function is to provide Drupal with the ability to host the same content with different paths at a "beta" sub-domain. Using the included sub-modules, editors can also test new or alternate layouts for their content, new blocks, new templates, etc. using the beta sub-domain all while leaving their content displaying normally at the default domain.

This project is the result of a need to restructure a large Drupal site, primarily from an Information Architecture standpoint. The module allows site owners to rearrange and restructure their content for the beta sub-domain while leaving current structures intact for the default domain.

When accessing the site using the beta sub-domain, all the links within the site are rewritten using the using the alternate, beta paths. This includes menus and all links which are dynamically created. The included sub-modules optionally extend active trail handling so that breadcrumbs and menus function as normal when accessing the beta site.

A block visibility plugin and a service is provided which can be used to alter other site content being accessed at the beta sub-domain. The core RequestPath block visibility condition is also altered to support the beta paths. This allows site owners to swap out blocks when accessing their sites with the beta sub-domain, e.g. have a different main menu for default vs. beta.

Site owners can use these features to allow previewing and beta testing of new features all while still being able to maintain their content within a single site, even directly on production environments.

The Beta Site module was created with the intent of integrating with Layout Builder. When using the complimentary modules listed below, Beta Site is a game-changer for Drupal, allowing editors to test their content in any layout while on beta and then launch at-will, simply by changing a field value. This alleviates the need to deal with development environments and copying content/media back and forth.

Additional Features

  • Includes a handy sub-module which provides a block that indicates if you're on beta or not with a link to allow toggling back and forth
  • Robots nofollow metatag added on pages accessed with beta sub-domain
  • Integration with RobotsTxt to set Disallow: / when site is accessed with beta sub-domain
  • Integration with Single Content Sync to provide node import/export functionality and preserve view mode selections
  • Integration with Menu Breadcrumb to support beta paths
  • Integration with Menu Trail By Path to support beta paths
  • Beta Site Switches sub-module that provides a UI to allow site owners to define switches for site features and set them to display for either the default domain, beta sub-domain, or both and a Twig extension is included for switching out features in templates - This is a port of the Switches module by Stephen Lucero

Complimentary Modules

  • View Mode Switch Field

    This module provides a new field type for storing view mode selections. It compliments Beta Site by allowing editors to select which view mode their content renders with when accessing the content at the beta domain.

  • Layout Builder Overrides

    This module extends Drupal to allow non-default view mode layouts to be overridden. This allows editors to have some nodes which deviate from a default layout, per view mode.

    Related issues: #2907413, #3002000, #3083754

Installation and Usage

  1. Ensure your webserver configuration allows your site to be accessed using a "beta" sub-domain, e.g. beta.mydomain.com. Drupal allows this by default, so there's no special configuration needed with it as long as the same document root directory is used. Production or public dev/testing environments will likely require a DNS entry for the beta sub-domain. Local users may need to add an entry to the hosts file or a value in the config.yml file for additional_hostnames when using DDEV.
  2. Install the module using "composer require drupal/betasite"
  3. Enable the module using the UI or "drush en betasite"
  4. Edit nodes and add values in the new "Beta URL alias" input field
  5. When you visit the site with the beta sub-domain, you should see the links to the nodes updated to use the new aliases in menus
  6. Use the new "Hostname" condition in the blocks UI to define which blocks should be shown or hidden when the site is accessed with the beta sub-domain
  7. Enable the "Beta Site Toggle Block" module (drush en betasite_toggle_block) and place the block in a region, typically above the content
  8. Visit the site and use the link in the block to switch back and forth between beta
  9. Enable and configure other sub-modules as needed - See individual sub-module README files for more information
Supporting organizations: 
sponsors development time

Project information

Releases