Was this article helpful?
Thanks for your feedback
You can preview your entry before publishing it on the production environment of your website or app in a few simple steps. Previewing your content is a two-step process that involves the creation of a Preview environment and then publishing content on this created environment.
Note: We now offer the Live Preview feature to preview your content changes in real-time without saving or publishing them to an environment. Contact our Support team to add the Live Preview feature to your Contentstack (organization) account subscription.
In this guide, you need to create a preview environment that will point to the location where a demo version of your application is hosted. Then, publish your content to this preview URL and view how your content will display on the live site.
Additional Resource: For websites developed using Gatsby and Contentstack, the Gatsby Preview extension lets you preview the content changes as soon as you make them.
Note: Contentstack no longer supports the ability to add multiple content deployment servers while setting up a specific publishing environment in Contentstack. We recommend that you instead make use of Webhooks to trigger deployment to multiple web servers whenever you publish content to an environment.
Let’s look at the steps in detail.
To add a preview environment, log in to your Contentstack account, navigate to your stack, and perform the steps given below:
This creates your preview environment.
Additional Resource: To know more about environments and how to work with them, check out the Environment section.
Let’s see how to publish your content on this preview environment.
Publishing your content on the preview environment can be done in two ways: Manual and Automatic.
In Manual method, users need to manually publish content on the preview environment in order to view their content. Whereas, in the Automatic method, users can write a script that will publish content every time an entry is either created or updated.
In this method, all you need to do is publish the item (entry or asset) in your preview environment whenever you want to view your content. This method gives you the flexibility to publish your content on your preview environment only when it’s required.
You can create a setup such that whenever you create or update an entry in your stack, it will be automatically published to the preview environment.
In this method, you’ll need to create a webhook that triggers whenever content is either created or updated. So, whenever a new item (entry or asset) is created or existing items are updated, this webhook will be triggered to send a notification each time to the URL of your choice.
To create a webhook, perform the steps given below:
Once this is done, save the webhook, and repeat the same process for adding webhooks for assets. Read more on Webhooks.
With this step, you have ensured that whenever you create or update an entry or asset, the webhook will be triggered. The details of the triggered event will be notified to the URL that you have specified in the webhook.
You need to set up a server and add a POST call to it that publishes content to the Preview environment. The URL of the POST call should be the URL to notify in your webhook. So, whenever you save content, the webhook will be triggered and the POST call will be executed.
After publishing your content on the preview environment, open your browser and point to http://localhost:4000. You should be able to see a basic structure of your content without any styling. If this content looks good to go ahead, you can then publish the content on the actual live site where your CSS stylesheet would make your content presentable.
Was this article helpful?
Thanks for your feedback