Next.js Pages Router
This guide assumes you are using the Next.js pages router.
Video Guide
Installing dependencies
From within your site's directory, run:
This will ask you a few setup questions. When prompted for the public assets directory, enter: public.
Updating your build scripts
tina init should have updated your package.json scripts.
These should be applied manually if they haven't been set by the CLI.
Starting TinaCMS
You can start TinaCMS with:
We recommend using pnpm.
With TinaCMS running, navigate to http://localhost:3000/admin/index.html.
If you are getting errors when running this command, please see the Common Errors page.
At this point, you should be able to see the TinaCMS admin, select a post, save changes, and see the changes persisted to your local markdown files.
TinaCMS Config file
After running the tina init command a few files were created to get you started as quick as possible. One of these is the tina/config.ts file. This is the a required config file that defines all the tina schemas.
It looks like the following:
For a more detailed overview about the config see Content Modeling with TinaCMS
💡 If you've followed this guide using thetina initcommand, you might have noticed that acontentand apagesfolder got created:
These can be used as a quick reference but are safe to delete.
Creating a New Post
💡 As defined in thetina/config.tsfile we have 1 collection calledpostwhich will be picked up by TinaCMS and mapped to what you see in the TinaCMS Admin page.
1.Head over to /admin/index.html
2.Click on Posts
3.Click on Create
4.Enter required fields
5.Save
Now, let's go back and check what was created. You will see a /content folder with your new post saved as a .md file. This path is defined in the tina/config.ts files post collection!
Rendering the Post Collection
Let's start by creating a /posts folder. The index here will list all our posts.
File: pages/posts/index.tsx
Rendering a Single Post
File: pages/posts/[slug].tsx
Next Steps
Check out the content modeling docs
Content Modeling with TinaCMS
Check out ›
Learn how to query your content
Content API Overview
Learn ›
Deploy Your Site
What is TinaCloud?
Deploy ›