Cover image for Building a blog using Frontity and WordPress
Frontity Framework

Building a blog using Frontity and WordPress

r_martinezduque profile image Reyes Martínez Updated on ・7 min read

This post was written by ✏️ Jesús Olazagoitia and originally published in Spanish at goiblas.com.

In this tutorial, I am going to show you how to create a personal blog using:

  • WordPress as database and a tool for creating content.
  • React to display the content and manage the UI components.
  • NodeJS to render on the server, and thus improve loading times and facilitate search engines crawl.

Luckily for us, other developers have already faced this challenge and created a framework called Frontity which will make this work far easier. You can check out their introductory post here and the official documentation at docs.frontity.org.


  • NodeJS installed in your computer.
  • Local install of WordPress, we’ll use Local by Flywheel for this tutorial.
  • A remote WordPress site.
  • A Zeit.co account to deploy a NodeJS server.

Set up Frontity 🚀

First, open the terminal, go to the directory where you will create your project, and run this command:

npx frontity create blog-name

Replace blog-name with the name of your project. Now access the folder and run the command:

npm run dev

This will open your blog at http://localhost:3000, where you should see it working. You will also see that its content is the one that comes by default with Frontity. The next step would be to show your own content.

First appearance of your blog: the content is the one that comes by default with Frontity, not your posts.

This should be the initial appearance of your blog.

To do so, you have to create a new site in your local by Flywheel with the default configuration.

Once it is working, copy the site’s url and return to your Frontity project. Open the file frontity.settings.js and look for the line where it states api. Then replace the address that comes by default (https://test.frontity.io/wp-json) with your site's url plus /wp-json (the address of the WP REST API). It should look like this: http://blog-name.local/wp-json.

If you refresh your blog, you should now be able to see your site’s content. Everything should be working fine except the menu, which points to some pages that are not created in your site.

Configure your menu

Frontity pulls data from your WordPress site, so the first thing you have to do is to create those pages that you'd like to show on your Frontity theme. We'll create a page called “Quiénes somos” (About us) for this example. We just have to add the link text and path in our frontity.settings.js configuration file:

In this example, we only added “Portada” (Homepage) and the “Quiénes Somos” (About Us) page, but there’s no limit on the number of pages. You can even add links to categories or tags, like in your traditional WordPress site.

As you can see, paths are the same as those that your WordPress uses. So let's say that you would like to change the url of your posts so that the dates are not shown, for example. You would have to do it from WordPress as usual, and not from Frontity.

Customize your theme

Frontity comes with a default theme called mars-theme, which you can use as a basis for creating your theme. The theme is located within the packages/mars-theme folder.

There you will find another folder called /src which contains: (1) an index.js file, where you can define and configure your theme; (2) a /components folder, where all the pieces that are part of your theme are.

If you are familiar with React and JSX, you’ll find it easy to add and modify components. One thing you should know is that Frontity comes with Emotion among its libraries (already integrated and configured), which allows you to write css styles with JavaScript.

You can find more information on how to style your Frontity theme here.

Emotion logo


Implement dark mode

As you customize your theme, you may want to add other functionalities. To do this, you will have to return to the index.js file of your theme’s /src folder.

There you’ll find: (1) state, where the global variables of our blog are defined; (2) actions, where the functions that will modify those variables are defined.

Let’s implement dark mode in our blog. The first step would be to define the state and the functions that will modify it.


Now that we have all the ingredients, it’s time to implement this functionality. First, go back to the /components folder of your theme and open the index.js file. Then, get the mode from your state. To simplify, you can add some styles to the body, similar to how the global styles are added.


As you can see in this example, we tell it: if mode is "light", use one color; if not, use another. It’s not a spectacular design but it will help you to see its behavior.

Now, let’s create a component which will allow you to change from one mode to another.


This should work fine but you still need to indicate which one is selected. To do so, you have to collect the information from the state. Then, with the help of emotion, you can add style to your component as well as modify the buttons so that they accept an attribute which will change its appearance when selected.


This component can be included in any part of your blog, in this example we included it in the header.


Add Disqus as comment system

Although you can use the native WordPress comments, Disqus can bring you some benefits, such as spam control or user identification.

Before starting, you will have to create an account on Disqus (if you don't have one already) and register a new site.

The good thing about using React for your theme is that you can take advantage of its rich ecosystem and use components from other developers that work great. In this example, we will use disqus-react to integrate Disqus. To install it, you can use this command:

npm install disqus-react

Now that you can use it on your blog, you will just need to import it and pass it an object with the url, an identifier and a title, so that Disqus knows which comment it has to show in each post. All the documentation of this React component can be found at github.com/disqus/disqus-react.

To get the information you need, you can help yourself from the state you receive thanks to Frontity. First, get the information from the current url:

const data = state.source.get(state.router.link);

Now, get your post using the type and id you have received from data:

const post = state.source\[data.type\]\[data.id\];

This is everything you need to build the object and create your comments component.

The next step would be to import it within your post component. Remember to render it only on the browser since Frontity provides you with server side rendering (which makes your code run first on the server, where you don’t have a window object and Disqus will give an error).

Through state.frontity.platform you can know where your code is running. In this case, you may want it to run when it is "client". And to show it only within your posts, you can use data.isPost.

{state.frontity.platform === "client" 
            && data.isPost
            && ( <Comments /> ) }

The last step would be to implement it through namespaces. Frontity uses state, actions and libraries, and all packages are used from there through a specific name. This means that if you create a package that exports:

libraries: {
       comments: {

You can use libraries in your post to do something similar to this:

const Post = ({ state, actions, libraries }) => {
return (
<libraries.comments.Comments />

What do you achieve with this? That if you replace your comment library in the future, your theme won’t be affected. You have more information on the use of namespaces in the official Frontity documentation: docs.frontity.org/learning-frontity/namespaces. If you want me to write a post about this topic, let me know. 😜

Publish your blog

Now that you have added style and some features to your blog, it’s time to show it to the world. To do this, you need to have a remote WordPress with the content - remember that we were working locally with Local by Flywheel. You have two options here, install and configure a WordPress blog manually in any web hosting, or use wordpress.com. Either option is perfectly valid.

Once you have your remote WordPress ready, you will have to update the frontity.settings.js configuration file by replacing the local url with the new location, like this:

If you restart your blog with npm run dev, you should see the content of the new WordPress site. If so, now you have to deploy your project in a NodeJS server.

To do so, you can use Now and follow these steps: docs.frontity.org/installation-and-deploy/deploy-on-now.

You will need to create a now.json file in the root folder of your project with the following content:

Then, create an account on Now at zeit.co/signup and log in the terminal using:

npx now login

Finally, publish your blog by running the following command:

npx now

And that's it! 🎉🎉🎉

Your blog is published and ready to be shown to the world!

Posted on by:

r_martinezduque profile

Reyes Martínez


Content and Communications at Frontity. When away-from-computer, I enjoy reading, traveling and photography.

Frontity Framework

Frontity is a free and open source framework for building amazing websites using WordPress and React.


markdown guide

Thanks @Reyes I'm interested in react & wordpress And I recently frontity it is amazing project , thank you for this awesome tutorial and here is my app frontity.moatazabdalmageed.vercel....


Thanks for sharing it, Moataz! Feel free to reach out to us in the community (community.frontity.org/) if you have any questions. 🙂