Documentation
Feedback
Guides
Storefront Development

Storefront Development
FastStoreIntegrating your storefront with Headless CMS
2. Setting up the Headless CMS
Now that you are familiar with the core concepts of the Headless CMS and have set it up in your VTEX account let's get back to our FastStore project to define our own Content Types and Sections.
By the end of this part of this tutorial, you will be able to see your first definition of a content type available for use in the Headless CMS app. Next, we will dive deeper into how to create these definitions in a smoother way.

Before you begin

Integrate the store with the Headless CMS

To add and manage sections on your store's pages, all sections must be available in the Headless CMS. To integrate your FastStore project, please refer to the Headless CMS integration track.

Install the FastStore CLI

Make sure to install the FastStore CLI to use its commands locally. Refer to the FastStore CLI guide for more information.
This guide assumes that you are starting without any existing CMS-related files. If your project already includes any of the following files: content-types.json or sections.json, follow the instructions in Step 1 - Creating the CMS folder to create only the necessary files for your project's requirements.

Instructions

Step 1 - Creating the CMS folder

  1. Open the terminal and change to the root directory of your FastStore project.
  2. Create a new folder named cms at the root of your FastStore project and a subfolder named faststore inside the cms. Run the following command to create them:
macOs and Linux
Windows

_10
mkdir -p cms/faststore

  1. Create the two files below inside the faststore folder by running the following command:
If your project already includes the CMS-related files: content-types.json or sections.json, create only the necessary files for your project's requirements.
macOs and Linux
Windows

_10
touch cms/faststore/content-types.json cms/faststore/sections.json

File nameDescription
content-types.jsonAn array of JSON objects that describes the Content Types available for customization at the Headless CMS app.
sections.jsonAn array of JSON objects that describes the content structure of the frontend Section components available for customization at the Headless CMS app.
  1. Update the sections.json file with an empty array:

_10
echo "[]" > cms/faststore/sections.json

  1. Open the content-types.json file in any code editor of your choice and add the following code:
cms/faststore/content-types.json

_47
[
_47
{
_47
"id": "landingPage",
_47
"name": "Landing Page",
_47
"configurationSchemaSets": [
_47
{
_47
"name": "Settings",
_47
"configurations": [
_47
{
_47
"name": "seo",
_47
"schema": {
_47
"title": "SEO",
_47
"description": "Search Engine Optimization options",
_47
"type": "object",
_47
"widget": {
_47
"ui:ObjectFieldTemplate": "GoogleSeoPreview"
_47
},
_47
"required": ["slug", "title", "description"],
_47
"properties": {
_47
"slug": {
_47
"title": "Path",
_47
"type": "string",
_47
"default": "/"
_47
},
_47
"title": {
_47
"title": "Default page title",
_47
"description": "Display this title when no other title is available",
_47
"type": "string",
_47
"default": "FastStore Starter"
_47
},
_47
"description": {
_47
"title": "Meta tag description",
_47
"type": "string",
_47
"default": "A beautifully designed store"
_47
},
_47
"canonical": {
_47
"title": "Canonical url for the page",
_47
"type": "string"
_47
}
_47
}
_47
}
_47
}
_47
]
_47
}
_47
]
_47
}
_47
]

Don't worry about the structure of this file for now, as we'll learn more about it later in this tutorial. However, notice that we have defined the Custom Page Content Type.
  1. Save your changes in the content-types.json file.
  2. Open the terminal and run yarn dev to enable the watch mode for the FastStore CLI. This command will monitor any changes in the project, including the new section you have created, and automatically merge it with the default sections available in faststore/core.

Step 2 - Syncing your changes

Let's now sync the changes with the Headless CMS app and see what happens.
  1. Open another terminal and log in to your VTEX account.
  2. Create a new development workspace by running the following command. Remember to replace the values between curly brackets according to your scenario:

_10
vtex use {workspace}

Use a development workspace to try your definitions of Sections and Content Types before syncing them with the VTEX master workspace.
  1. Change to the root directory of your FastStore project.
  2. Sync your changes in the cms folder with the Headless CMS app:

_10
faststore cms-sync

If you have the @vtex/cli-plugin-cms@1.0.7 installed you can use the {builderName} argument to synchronize a specific builder: vtex cms:sync {builderName}.
Once your changes are synced with the Headless CMS, the terminal will show the following message:

_10
CMS synced successfully...

Step 3 - Checking your changes

  1. Access the VTEX Admin using the workspace you created in Step 2 -Syncing your changes by navigating to the following path: https://{workspace}--{account}.myvtex.com/admin. Make sure to replace {workspace} with the designated workspace name and {account} with your VTEX account.
  2. Go to Storefront > Headless CMS.
  3. Click on Create New.
{"base64":"  ","img":{"width":1170,"height":751,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":57056,"url":"https://vtexhelp.vtexassets.com/assets/docs/src/headless-custom-page___c952670d0592c3c66202d6702af3fc17.png"}}
You should now see the content type we created in the previous step available for use in the Headless CMS app. However, no Sections will be available yet. We'll learn more about this in the following part of this track, Structuring Content Types and Sections.
Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
On this page