Add an Environment

An environment refers to the content delivery destination where you publish and deploy the entries of your application or website.

To add an environment, log in to your Contentstack account, and perform the following steps:

  1. Go to your stack, navigate to the “Settings” gear icon at the top, and select Environments.
  2. Click on + New Environment.
  3. The Create Environment form appears for you to add the following details:
    • Name: Enter a name for the environment, such as “staging,” “production,” “development,” and so on.
    • Base URL: It is the consistent part of the destination’s web address (for example, http://localhost:4000, http://www.example-site.com) where the content will be published. The base URL is used as a prefix when the URL of an entry is generated. It is important to note that base URL would be different if using different languages (for example, http://www.example-site.com/en/).

      Tip: If you wish to preview your published content, you need to provide the address of your localhost as the base URL of the environment, i.e., http://localhost:4000. Now, after publishing your content, point your browser to 'http://localhost:4000/{relative-url-of-the-published-entry}' in order to view the published content on your browser. Alternatively, you can click on the "eye" icon in the URL field of your entry page to get the URL.

      In case of mobile apps or other devices, you need not enter the base URL. This is because apps fetch content directly from Contentstack servers through APIs.

    • Advanced (optional) - The Advanced option lets you add advanced settings to your environment. Click the “Advanced” link to display the Deploy Content to Server(s) checkbox. When you select this option, every time you publish an item to the corresponding environment, Contentstack saves a copy in the local web server.

      Subsequently, whenever an incoming page request is received, the content will be retrieved and rendered directly from the local server, instead of fetching it from the Contentstack database via APIs. This process is also known as “push publishing.”

      It is recommended that you select this option only if you are using our web framework (contentstack-express) for your websites.

      Warning: contentstack-express framework has been deprecated. We will soon stop supporting this framework. Instead, we recommend using DataSync, which is faster and more flexible than the web framework.

      For apps, unlike web pages, the content is not pushed to any external servers. Instead, the app fetches content directly using Content Delivery API. Therefore, there is no need to deploy content to servers. In this case, disabling the Deploy Content to Server(s) option will let you publish the entry over an environment without deploying the content on the server.

Tutorial Video

In this short video, we will create a development environment with base URL as http://localhost:4000.

Add an Environment.png

Preview your Entry

Hover on the Preview (eyeball) icon beside the URL field to view the URLs of all the environments in which the entry has been published. Click any of the links to visit the web page and view the entry.

Eyeball.png

API Reference

To perform the add action via API request, refer to the Add an environment API request

On This Page

top-arrow