Was this article helpful?
Thanks for your feedback
Here’s a quick guide that explains how to create a basic webpage in Contentstack in under 5 mins.
Note: Learn how to use the Bootstrap plugin in Contentstack CLI to automate the project setup process for starter apps.
The steps to be followed are given below:
Let’s look at the steps in detail.
First, you need to create a stack that will hold all the data to your project.
Note: If you are using a trial account with a sample stack, you can select that stack and move on to the next step.
To create a new stack, log in to your Contentstack account and perform the steps given below:
This creates your “My Website” stack. Read more about Stacks.
Next, let’s structure the pages of your website using content types.
Content types define the structure or blueprint of your web page.
Learn more About Content Types.
Based on the structure of your webpage, you can create either a Webpage (for web pages, e.g., homepage, contact page, etc.) or Content Block (for reusable content blocks, e.g., header, footer, menu, etc.) content type.
Next, mark your content type as either Single (to create a single entry) or Multiple (to create multiple entries with the same structure).
Now, let’s see the steps to first create a Homepage content type:
Refer to the Content Modeling and Content Type documentation to know more.
Your “Homepage” content type is ready to use. You can now use this content type to create entries.
We need to add a publishing environment that corresponds to one or more deployment servers or a content delivery destination where you can publish the entries.
Learn more About Environments.
To add an environment in Contentstack, go to your stack and perform the following steps:
Now you are ready to create your content.
Now, to add an entry for your “Homepage” content type, go to your stack, click the “Entries” icon on the left navigation panel and perform the steps given below:
With this step, you have created sample data for your website.
To publish your content, perform the following steps:
This publishes your content in your publishing environment.
The published content is accessible via Content Delivery APIs. You can use the following request using any third-party REST API clients (e.g., Postman) to get a single entry. Learn more about Content Delivery API.
https://cdn.contentstack.io/v3/content_types/{content_type_uid}/entries/{entry_uid}?environment={environment_name}
You will find both the content_type_uid and entry_uid details in the entry page:
In place of environment_name, you need to pass the name of your environment.
The response of the above API request returns a structured JSON object as follows:
{ "entry":{ "locale":"en-us", "title":"Contentstack", "url":"/home", "image":{ "uid":"blta07d95f7872eb58e", "created_at":"2019-08-05T10:54:54.628Z", "updated_at":"2019-08-05T10:54:54.628Z", "created_by":"bltaaba5fbac0ff0622", "updated_by":"bltaaba5fbac0ff0622", "content_type":"image/png", "file_size":"1096", "tags":[ ], "filename":"cs.png", "url":"https://images.contentstack.io/v3/assets/bltfa9026798819a8a2/blta07d95f7872eb58e/5d480afe19e55743594783fb/cs.png", "ACL":[ ], "is_dir":false, "_version":1, "title":"cs.png", "publish_details":{ "environment":"bltd43777d94dc2c16f", "locale":"en-us", "time":"2019-09-18T07:27:23.643Z", "user":"bltaaba5fbac0ff0622" } }, "description":"ContentstackTM is the hub powering omnichannel content, digital experiences and personalized customer journeys. It is the industry leader in the headless content management system (CMS) category. Marquee customers include Amway, Best Buy, Cisco, Dell, Ellie Mae, Express, Farm Bureau Insurance, J.D. Power, Marriott, Martha Stewart, Miami HEAT, and Sky. Contentstack sits at the heart of an award-winning Digital Experience Platform (DXP) and is the exclusive API-first CMS for the SAP Cloud.", "tags":[ ], "uid":"blt619fd79eea73f3cc", "created_by":"bltaaba5fbac0ff0622", "updated_by":"bltaaba5fbac0ff0622", "created_at":"2019-08-05T10:55:05.499Z", "updated_at":"2019-08-05T10:55:05.499Z", "ACL":{ }, "_version":1, "_in_progress":false, "publish_details":{ "environment":"bltd43777d94dc2c16f", "locale":"en-us", "time":"2019-09-18T07:27:23.643Z", "user":"bltaaba5fbac0ff0622" } } }
Till now, you have developed a sample web page and seen how to fetch your content. Now let’s see how to display the content on the web page.
To design our web page, we have used the following tools:
For your reference, we have already created a demo web page using CodeSandbox.
You can explore and try out our Content Delivery and Content Management REST API requests. We also have our very own GraphQL APIs that you can explore.
Contentstack also provides Postman collections of our Content Delivery, Content Management, and GraphQL APIs which will help you to get started with the APIs and try them out through the Postman client. To get started with the the Postman collections, download the latest version of the Postman collection(s) and the Postman app, set your Contentstack account-specific values in the collection environment, and try out our APIs with ease.
You can also try out our platform-specific SDKs or write your own.
Was this article helpful?
Thanks for your feedback