A portfolio using Sanity.io (for structured content) and Gatsby (as a static site generator) within a Yarn monorepo.
Because pushing directly to main
is impossible, all changes are managed through issues, feature branches, and pull requests (PRs)—ensuring clarity, collaboration, and minimal downtime when integrating new features or fixes.
This repository includes:
- web: The Gatsby front-end
- studio: The Sanity Content Studio (schemas and content)
Root package.json
highlights:
build-studio
: Builds the Studio ((cd studio && yarn run build)
).export-db
/import-db
: For exporting/importing production dataset.deploy-graphql
: Deploys updated GraphQL schema.clone
: Clones the production dataset into the development dataset.prepare
/postinstall
: Hooks for setting up Husky (Git hooks).
Refer to the package.json
files in each workspace for workspace-specific scripts.
-
Clone the repo
git clone -
Verify Yarn is installed
yarn --version -
Install dependencies (in the root folder)
cd ainc-gatsby-sanity
yarn install
Before making any changes, create a GitHub issue describing the task or feature:
-
Create an issue
- Provide a clear title and description of what you want to accomplish.
- Specify whether it affects
web
,studio
, or both.
-
Create a branch off the issue
git checkout -b feat/-- Example:
feat/42-add-new-schema-field
- Example:
-
Navigate to
web
cd web
yarn dev- The Gatsby dev (development) server runs at http://localhost:8000.
-
Edit code in the
web
folder- Changes appear automatically (hot reload).
-
Build (production)
- From
web
:
yarn build - This creates a production-ready build in
web/public
.
- From
-
Navigate to
studio
cd studio
yarn dev- The Studio runs at http://localhost:3333.
-
Schema or content updates
- Edit files in
studio/schemas
(or your chosen directory). - See your changes in real time in the local Studio.
- Edit files in
If schema changes in the Studio require corresponding updates in Gatsby, handle them together in a single feature branch.
-
Create a branch off the issue
git checkout -b feat/-- Example:
feat/15-update-schema-and-frontend
- Example:
-
Edit the schema in
studio
- Make necessary updates and test locally:
cd studio
yarn dev
- Make necessary updates and test locally:
-
Update Gatsby in
web
- Adjust GraphQL queries/components to match the new schema fields.
- Test by running
yarn dev
inweb
.
-
Commit changes (both
studio
andweb
)
git add .
git commit -m "Update schema and front-end for issue <#>" -
Push and open a PR
git push origin feat/-- Link the PR to the corresponding GitHub issue.
-
Merge and Deploy
- After PR approval:
- Merge into
main
. - Redeploy the GraphQL schema if needed:
yarn deploy-graphql - Deploy the updated Gatsby site.
- Merge into
- After PR approval:
-
Create an issue and branch
git checkout -b feat/- -
Edit schema in
studio
- Test with
yarn dev
.
- Test with
-
Commit and push
git add .
git commit -m "Studio-only changes for issue <#>"
git push origin feat/- -
Open a PR, merge, and redeploy GraphQL if necessary
yarn deploy-graphql
-
Create an issue and branch
git checkout -b feat/- -
Edit code in
web
- Test with
yarn dev
.
- Test with
-
Commit and push
git add .
git commit -m "Web-only changes for issue <#>"
git push origin feat/- -
Open a PR, merge, and deploy the updated Gatsby site
If production has updates that need to be synced to development:
- Update production content in the live Studio.
- Clone production into development:
cd studio
yarn clone- This exports the production dataset and imports it into the development dataset (
--replace
by default).
- This exports the production dataset and imports it into the development dataset (
- Restart local environments to ensure everything is up to date.
-
Use Issues for Every Task
- Create an issue describing the task or change.
- Reference the issue in your branch name and commits.
-
Small, Focused PRs
- Avoid mixing unrelated changes in a single PR.
-
Test Locally First
- Verify schema changes (
studio
) and front-end queries (web
) before opening a PR.
- Verify schema changes (
-
Deploy in Sync
- Merge and deploy schema changes first (or in the same PR) to prevent querying fields that don’t exist yet.
-
Communication
- Let teammates know if your changes might break existing queries.
- Gatsby Docs: https://www.gatsbyjs.com/docs/
- Sanity Docs: https://www.sanity.io/docs
- Import/Export Data: https://www.sanity.io/docs/migrating-data