Deploying Your Docs
Once you've set up your TinaDocs site locally and configured TinaCloud, the next step is deploying it to a hosting provider. This guide will walk you through the process, with a focus on deploying to Vercel.
Prerequisites
Before deploying, ensure you have:
- A TinaCloud project set up (see Setting Up TinaCloud)
- Your repository fully configured with TinaCMS
- Environment variables for
NEXT_PUBLIC_TINA_CLIENT_ID
andTINA_TOKEN
Setting Up Environment Variables
For your deployment to work correctly, you must set the following environment variables on your hosting provider:
You can find these values in your TinaCloud dashboard:
- Client ID: In the "Overview" tab of your project
- Token: In the "Tokens" tab of your project
Configuring Your Build Command
To ensure the TinaCMS admin interface is built alongside your site, your build command should run tinacms build
before your site's build command:
This creates the admin interface at /admin/index.html
in your final build.
Deploying to Vercel (Recommended)
Vercel is the recommended hosting provider for TinaDocs sites due to its seamless integration with Next.js.
Step 1: Connect Your Repository
- Log in to Vercel
- Click "Add New Project"
- Connect your GitHub repository
- Select the repository containing your TinaDocs site
Step 2: Configure Build Settings
In the configuration screen:
- Leave the framework preset as "Next.js"
- Modify the build command if needed:
- If your package.json has a build script like
"build": "tinacms build && next build"
, you can leave the default setting - Otherwise, set the build command to:
tinacms build && next build
Step 3: Set Environment Variables
Add your TinaCMS environment variables:
- Expand the "Environment Variables" section
- Add the following variables:
NEXT_PUBLIC_TINA_CLIENT_ID
= Your TinaCloud Client IDTINA_TOKEN
= Your TinaCloud Read-Only Token
- Add any other environment variables your project requires
Step 4: Deploy
Click "Deploy" and Vercel will build and deploy your TinaDocs site.
Step 5: Configure Branch Settings (Optional)
For production branch settings:
- Go to your project settings in Vercel
- Navigate to "Git" section
- Configure your production branch (typically "main")
Other Deployment Options
Netlify
- Connect your GitHub repository to Netlify
- Set the build command to:
tinacms build && next build
- Set the publish directory to:
out
(for static export) or.next
(for server rendering) - Add the TinaCMS environment variables in the Netlify dashboard
GitHub Pages
- Create a GitHub workflow file (
.github/workflows/deploy.yml
) - Configure the workflow to set environment variables
- Use the
tinacms build && next build
command - Set up GitHub Pages to deploy from your build output
Testing Your Deployment
After deploying, verify that:
- Your site is accessible at your domain
- The TinaCMS admin interface works at
/admin/index.html
- You can log in and make edits that are saved to your repository
Troubleshooting
If you encounter issues:
- Admin page not found: Ensure your build command includes
tinacms build
- Authentication failures: Check that your environment variables are correctly set
- Content not updating: Verify your TinaCloud project has the correct site URL configured
- Branch issues: Ensure your branch configuration in
tina/config.js
is correct
For more details, visit the official TinaCMS deployment documentation.