This project uses a Yarn monorepo with two primary workspaces:
- webs: A Gatsby site (front-end).
- studio: A Sanity Content Studio (schema and content management).
Because pushing directly to main is impossible, changes must be managed through issues, feature branches, and pull requests (PRs). This workflow ensures clarity, collaboration, and minimal downtime when integrating changes.
-
Clone the repo
git clone <your-repo-url> -
Install dependencies (in the root folder)
cd hof-gatsby-sanity cd webs yarn installcd hof-gatsby-sanity cd studio yarn install -
Verify Yarn is installed
yarn --version
Before making any changes, create a GitHub issue describing the task or feature:
-
Create an issue:
- Provide a clear title and description of the task, including any affected areas (
webs,studio, or both).
- Provide a clear title and description of the task, including any affected areas (
-
Create a branch off the issue:
git checkout -b feat/<issue-number>-<short-description>- Example:
feat/42-add-new-schema-field
- Example:
-
Navigate to
webscd webs yarn develop- The Gatsby dev (development) server runs at http://localhost:8000.
-
Edit code in the
websfolder.- Changes appear automatically (hot reload).
-
Navigate to
studiocd studio yarn dev- The Studio runs at http://localhost:3333.
-
Schema or content updates
- Edit files in
studio/schemasand see changes in the local Studio.
- Edit files in
If schema changes in Sanity require corresponding updates in Gatsby, handle them together in a single feature branch.
-
Create a branch off the issue:
git checkout -b feat/<issue-number>-<description>- Example:
feat/15-update-schema-and-frontend
- Example:
-
Edit the schema in
studio:- Make the necessary updates and test locally:
cd studio yarn dev
- Make the necessary updates and test locally:
-
Update Gatsby in
webs:- Adjust GraphQL queries/components to match the schema changes.
- Test by running
yarn developinwebs.
-
Commit changes (both
studioandwebs):git add . git commit -m "Update schema and front-end for issue <#>" -
Push and open a PR:
git push origin feat/<issue-number>-<description>- Open a PR linking back to the issue.
-
Merge and Deploy:
- After the PR is approved:
- Merge into
main. - Redeploy the GraphQL schema:
cd studio yarn deploy-graphql - Deploy the updated Gatsby site.
- Merge into
- After the PR is approved:
If changes only affect the Studio:
-
Create an issue and branch:
git checkout -b feat/<issue-number>-<studio-description> -
Edit schema or content structures in
studio:- Run
yarn devand test locally.
- Run
-
Commit and push:
git add . git commit -m "Studio-only changes for issue <#>" git push origin feat/<issue-number>-<studio-description> -
Open a PR, merge, and redeploy the GraphQL schema if necessary:
yarn deploy-graphql
If changes only affect the Gatsby site:
-
Create an issue and branch:
git checkout -b feat/<issue-number>-<webs-description> -
Edit code in
webs:- Run
yarn developand test locally.
- Run
-
Commit and push:
git add . git commit -m "Webs-only changes for issue <#>" git push origin feat/<issue-number>-<webs-description> -
Open a PR, merge, and deploy the updated Gatsby site.
If the production environment has updates needed in development:
-
Update production data in the live Studio.
-
Clone production into development:
cd studio yarn clone- This exports the production dataset and imports it into the development dataset.
-
Restart local environments to ensure all data is up to date.
-
Use Issues for Every Task
- Before starting any work, create an issue describing the task or change.
- Reference the issue in your branch name and commit messages.
-
Keep PRs Small and Focused
- Avoid combining unrelated changes in one PR.
-
Test Locally First
- Ensure schema updates and front-end changes are thoroughly tested locally before creating a PR.
-
Deploy in Sync
- Merge schema changes first (or simultaneously) before deploying front-end updates that depend on them.
-
Communicate
- Share changes that could impact other developers, especially schema modifications.
This project uses Gatsby's image optimization with Sanity CMS for optimal performance and user experience.
The project includes:
- ✅
gatsbyImageDatafrom Sanity for optimized images - ✅
GatsbyImagecomponent for automatic optimization - ✅
getImage()helper function for image processing - ✅ Proper image plugins in
gatsby-config.js - ✅ Reusable
OptimizedImagecomponent - ✅ Image optimization utilities
Always specify dimensions and formats in your GraphQL queries:
profilePhoto {
asset {
gatsbyImageData(
width: 300
height: 300
placeholder: BLURRED
formats: [AUTO, WEBP, AVIF]
)
}
}Use these standard dimensions for different contexts:
- Profile Photos: 300x300px
- Card Images: 400x250px
- Hero Images: 1200x600px
- Video Thumbnails: 430x275px
- Thumbnails: 150x150px
Always include multiple formats for better browser support:
AUTO- Original formatWEBP- Modern, efficient formatAVIF- Latest, most efficient format
BLURRED- Shows a blurred version while loadingDOMINANT_COLOR- Shows the dominant colorNONE- No placeholder
import { GatsbyImage, getImage } from "gatsby-plugin-image";
const MyComponent = ({ data }) => {
const image = getImage(data.profilePhoto.asset.gatsbyImageData);
return (
<GatsbyImage
image={image}
alt="Profile photo"
loading="lazy"
/>
);
};import OptimizedImage from "../components/OptimizedImage/OptimizedImage";
const MyComponent = ({ data }) => {
return (
<OptimizedImage
image={data.profilePhoto}
alt="Profile photo"
className="profile-photo"
sizes="(max-width: 768px) 100vw, 300px"
/>
);
};For responsive images, use the sizes attribute:
asset {
gatsbyImageData(
placeholder: BLURRED
formats: [AUTO, WEBP, AVIF]
sizes: "(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw"
)
}- Lazy Loading: Always use
loading="lazy"for images below the fold - Proper Alt Text: Include descriptive alt text for accessibility
- Sizes Attribute: Use appropriate sizes for responsive images
- Format Selection: Let the browser choose the best format with
AUTO - Placeholder: Use
BLURREDplaceholders for better perceived performance
In your Sanity schema, ensure image fields have proper validation:
{
name: 'profilePhoto',
title: 'Profile Photo',
type: 'image',
options: {
hotspot: true, // Enables focal point selection
},
fields: [
{
name: 'alt',
type: 'string',
title: 'Alternative text',
description: 'Important for SEO and accessibility',
validation: Rule => Rule.required(),
},
],
}- Images not loading: Check if
gatsbyImageDatais properly queried - Blurry images: Ensure dimensions are appropriate for the display size
- Slow loading: Use lazy loading and proper placeholder types
- Missing alt text: Always include descriptive alt text
Use the browser's developer tools to:
- Check network tab for image requests
- Verify image formats being served
- Test responsive behavior
- Validate accessibility
Track image performance using:
- Lighthouse audits
- Core Web Vitals
- Network tab analysis
- User experience metrics
- Gatsby Docs: https://www.gatsbyjs.com/docs/
- Sanity Docs: https://www.sanity.io/docs
- Image Optimization Guide: See section 8 above for detailed image optimization practices
- Gatsby Image Plugin: https://www.gatsbyjs.com/plugins/gatsby-plugin-image/