A Gatsby v5 blog with Markdown-based posts, syntax highlighting, reading time, dark mode, and Firebase Hosting deployment.
- Framework: Gatsby v5 (React 18)
- Styling: CSS modules
- Markdown:
gatsby-transformer-remark
+gatsby-remark-prismjs
- Images:
gatsby-plugin-image
,gatsby-plugin-sharp
,gatsby-transformer-sharp
- Head/SEO:
react-helmet
- Deploy: Firebase Hosting
The Gatsby site lives under public/blog
and builds into public/blog/public
.
root
├─ firebase.json # Firebase hosting config (publishes public/blog/public)
└─ public/
└─ blog/
├─ content/blogs/ # Markdown posts (with frontmatter)
├─ src/
│ ├─ assets/ # Favicons, PWA icons, etc.
│ ├─ components/ # UI components (e.g., layout.js)
│ ├─ images/ # Local images used in posts/pages
│ ├─ pages/ # Top-level pages
│ └─ templates/ # Blog post template
├─ gatsby-*.js # Gatsby config files
└─ package.json
- Node.js: 18.x or newer (required by Gatsby v5)
- npm: 8+ (bundled with Node 18)
- Optional:
firebase-tools
for deployment
Run everything from the Gatsby app directory:
cd public/blog
npm install
npm run develop
Open http://localhost:8000
in your browser.
npm run develop
: Start Gatsby dev servernpm run build
: Build production assets intopublic/blog/public
npm run serve
: Serve the production build locallynpm run clean
: Clear Gatsby cachesnpm run format
: Run Prettier on the codebase
Create Markdown files in public/blog/content/blogs/
. Each post should include frontmatter:
---
title: "Post Title"
date: "2024-06-01"
path: "/my_post_path"
desc: "Short description for SEO"
---
Your Markdown content goes here.
- Required frontmatter:
title
,date
,path
,desc
- Posts are rendered using
src/templates/blogTemplate.js
- Place general images in
public/blog/src/images/
and reference them in components/pages. - PWA icons and favicons are in
public/blog/src/assets/
and configured viagatsby-config.js
. - The footer icon is configured in
src/components/layout.js
and usessrc/assets/redbull.png
.
Update site metadata in public/blog/gatsby-config.js
under siteMetadata
:
- title: Blog title
- description: Default site description
- author: Handle or name
- siteUrl: Canonical site URL
cd public/blog
npm run build
Artifacts will be output to public/blog/public
.
This repo includes firebase.json
configured to host the Gatsby build output directory public/blog/public
.
- Build the site:
cd public/blog
npm run build
- Deploy from the repository root:
cd ../.. # back to repo root
firebase deploy --only hosting
Notes:
- Install the CLI if needed:
npm i -g firebase-tools
- Login once:
firebase login
- If you see errors related to Node version, ensure Node 18+.
- After changing plugins/config, try
npm run clean
thennpm run develop
. - If images don’t appear, verify source paths and that
gatsby-source-filesystem
includes the directory.