Support Home > Staging Sites

Staging Sites

Set up a Jetpack staging site to test changes safely by marking the site as a staging environment, so Jetpack keeps your live site settings and connection protected from changes made during testing.

When you make a copy of your site for testing or development, Jetpack checks the WP_ENVIRONMENT_TYPE variable in the wp-config.php file. This variable was added in WordPress 5.5 and tells WordPress and plugins whether a site is a production, staging, or development environment. If the variable is set to staging or development, Jetpack turns off the option to move site settings to the test site. This protects the live site from changes made in the test environment.

Note: This guide covers online staging sites. If you have a local offline development site, follow the Offline Mode guide instead.

Mark your site as a staging environment

Before Jetpack can recognize a site as staging, the WP_ENVIRONMENT_TYPE variable must be set to staging. Some hosts set this variable automatically when you create a staging site through their built-in staging tools. Check with your hosting provider to see if they offer a built-in staging workflow that sets this value for you.

If your host does not set the variable automatically, add it to the wp-config.php file on your staging site:

  1. Connect to your staging site over SFTP, or use your host’s file manager.
  2. Open the wp-config.php file in the root directory of your WordPress installation.
  3. Add the following line above the line that reads /* That's all, stop editing! Happy publishing. */:
    define( 'WP_ENVIRONMENT_TYPE', 'staging' );
  4. Save the file and upload it back to the server if you edited it locally.

You can set the value to staging or development. Both values cause Jetpack to turn off the option to move site settings from the production site. This variable is used by many plugins and web hosts to identify non-production environments.

The steps for moving changes between your staging and production sites depend on whether you set the WP_ENVIRONMENT_TYPE variable manually or your host sets it automatically. Use the process that matches your setup.

Set the environment type manually

If you set the WP_ENVIRONMENT_TYPE variable yourself, follow these steps to move changes between your production and staging sites:

  1. Migrate the database from your production site to your staging site.
  2. Set WP_ENVIRONMENT_TYPE to staging on the staging site.
  3. At the Safe Mode prompt, click Create a fresh connection.
  4. Make your changes on the staging site.
  5. Migrate your changes back to your production site.
  6. When you open WP Admin on your production site, the Safe Mode prompt displays again because the site looks new to Jetpack.
  7. Click Create a fresh connection to restore the original connection on the production site.

Use a host that sets the environment type automatically

If your hosting provider sets the WP_ENVIRONMENT_TYPE variable for you, follow these steps:

  1. Clone your production site to staging.
  2. The staging site enters Safe Mode.
  3. Click Create a fresh connection.
  4. Make your changes on the staging site.
  5. Move your changes to production.
  6. On the production site, the Safe Mode warning displays again.
  7. Click Create a fresh connection, because this is now a new connection compared to the staging environment.

Choose a Safe Mode option

When your Jetpack site is accessed in staging for the first time, you see a Safe Mode warning because Jetpack notices that the staging site is a copy of your production site. You have three options:

  1. Move Jetpack data from your production site to the staging site. This option is not available if the site is marked as staging through WP_ENVIRONMENT_TYPE.
  2. Treat each site as an independent site by creating a fresh Jetpack connection.
  3. Decide later and stay in Safe Mode. Staying in Safe Mode is best when:
    • The site is created for short-term testing and will be deleted soon.
    • The site will be cloned back to production after testing.

Jetpack features that do not work in Safe Mode

The following Jetpack features do not work while a site is in Safe Mode:

Re-enable connection migration (for developers)

This section is for developers. If your site has WP_ENVIRONMENT_TYPE set to staging but you still need to enable connection migration, you can override Jetpack’s behavior with a filter. Use this only when you understand the effect of moving connection data between environments.

Add the following filter to re-enable connection migration:

add_filter( 'jetpack_is_development_site', '__return_false' );

You can add this code to any existing plugin, or use the Code Snippets plugin or a similar plugin.

Still need help?

Please contact support. We’re happy to advise.

  • Table Of Contents

  • Contact Us

    Need more help? Feel free to contact us.