Tina supports sourcing content from a separate Git repo. With this approach you can continue to define your Tina config in your "website repo", but documents will be saved elsewhere.
You might want to do this for a variety of reasons, such as:
Throughout this guide we'll be referring to a "website repo" and a "content repo". The "website repo" is where your actual website is running, while the "content repo" is where you'll be storing your markdown content
We have deployed a basic starting "website repo", which you can clone to get started.
git clone git@github.com:tinacms/separate-website-repo.git
The "website repo" contains the NextJS site, and the tina
config.
To set up the "content repo", we'll start with a simple .mdx
file:
mkdir -p ../demo-content-repo/content/pages && touch ../demo-content-repo/content/pages/home.mdx && echo "Hello" >> ../demo-content-repo/content/pages/home.mdx
This command created a folder (demo-content-repo
) and added a single MDX file to it in the content/pages
directory, we'll be using that directory for the page
collection defined in the Tina config.
In the "website repo", install the project's dependencies
yarn install
Run the project locally:
yarn dev
Open http://localhost:3000/admin/index.html
From here you can add more fields to you content models in tina/config.js
. Visit the docs to learn more about content modeling.
Next we'll want to create a TinaCloud project from our "content repo"
Initialize Git in your content repo and push it to GitHub. From there connect to TinaCloud
Once that's done, create a token for the main
branch, or use *
to allow all branches.
Switch back to your "website repo" and set up an .env
file to use when connecting to TinaCloud:
cp .env.example .env
When you run tinacms build
, it will use those credentials to connect to TinaCloud rather than the local server:
yarn build
To learn more about Tina, take a look at the following resources:
You can check out Tina GitHub repository - your feedback and contributions are welcome!
Last Edited: January 1, 1970© TinaCMS 2019–2024