All of the code shown in this tutorial is also hosted in our GitHub repository.
1. A Webiny Project
First of all, make sure you have a working Webiny project set up.
When setting up a new project, currently, there are two project templates you can choose from:
cms. Both include the Headless CMS app by default.
2. Content Delivery API URL
The Headless CMS app exposes data via the Content Delivery API, which is a simple GraphQL API that dynamically updates its schema on content model changes that you make.
Once you've deployed your API stack (using the
yarn webiny deploy api command), you should be able to find the Content Delivery API URL in the console output:
3. Content Delivery API Access Token
In order to access the data via the Content Delivery API, we'll need a valid Access Token. These can be created via the Access Tokens form, which you can reach via the main menu:
Create a new token and make sure to copy the actual token string. We'll need it soon.
Creating our first content model
Now that we have all of the prerequisites out of the way, it's time to create our first content model. Let's open the Models section of the Headless CMS app.
Let's create a new content model named Blog Post. Click on the "plus" icon in the lower right corner of the screen and in the dialog that's about to be shown, enter the following:
For the content model group, we'll use the
Ungrouped, which is the default group that comes out of the box with every Headless CMS app installation.
Content model groups give you a way to organize the content models inside the main menu, allowing you to build logical sections for your content editors. You can click here to learn more.
Once we've submitted the form in the dialog, we should be redirected to the Content Model Editor. Let's add three fields:
title as a
description as a
Long Text, and
image as a
Files field. They will match every fact's title, description and image, respectively.
Save the changes by clicking on the Save button in the top right corner of the screen.
Now it's time to create the actual content. Proceed by clicking on the View content button, located on the left side of the Save button.
You can also reach the content area by clicking on the newly added Fact item in the main menu:
As mentioned, navigate to Headless CMS > Ungrouped > Fact and create couple of facts. Feel free to unleash your creativity. 😉
Once you feel happy with the facts, you can save the changes by clicking the Save button, located at the bottom of the form.
The next and final step is to publish the blog post, which will make it actually visible in the Content Delivery API. To do that, click on the Publish icon, found at the right side in the form header.
Now that we've covered the basics of creating content models and managing content, we can move on to the Vue.js part of this tutorial.
Creating a new Vue.js app
We can create a new Vue.js app by running this command.
For this example we'll use
coffeeshop as the project name, and the
default preset with it.
Ideally, you should create your Vue.js project in a folder outside of the Webiny project.
Now that we have a new Vue.js app ready to go, let's see what it takes to make a simple page that renders a list of all interesting facts about coffee that we've just created.
We're going to start off by installing few NPM packages:
These will help us with fetching the actual content from the Content Delivery API.
In your Vue.js project root, run the following command:
Once we have these ready, we can jump to the code. The following snippet shows the code located in the
Now we will add this apollo Client to our Vue app so that we can fetch the content from the Content Delivery API.
Let's head over to
Finally let's render some mark up 🙂
Head over to
Previewing the page
yarn serve in our Vue.js project directory so we can see our page in action:
We've successfully created a simple page that displays a list of all created facts, powered by Webiny Headless CMS and Vue.js.