How to Add a New Blog Post
1. Create a Markdown File
Create a new file in this directory with the naming convention: blog_XXX.md (e.g., blog_005.md)
2. Add Frontmatter (Optional but Recommended)
Start your markdown file with YAML frontmatter to specify metadata:
---
date: 2024-03-14
author: CodeDD Team
featured: true
image: /path/to/cover-image.jpg
---
# Your Blog Post Title
## Your Subtitle
Your content here...
Available Frontmatter Fields:
- date (recommended): Publication date in YYYY-MM-DD format. If not provided, file modification date will be used.
- author (optional): Author name. Default: "CodeDD"
- featured (optional): Set to
trueto feature this post. Default:false - title (optional): Override the title extracted from the first
#heading - description (optional): Override the subtitle extracted from the first
##heading - image (optional): Path to cover image. Can also be set in
blogPosts.js
3. Write Your Content
Use standard markdown formatting:
# Main Title (H1)
## Subtitle (H2)
### Section Heading (H3)
Regular paragraph text.
- Bullet point
- Another bullet point
**Bold text** and *italic text*
[Link text](https://example.com)

4. Build Process
When you run npm run build, the following happens automatically:
-
Pre-build: The
generate-blog-routes.jsscript runs and:- Scans all
.mdfiles in this directory - Extracts titles and slugs
- Generates routes for react-snap pre-rendering
- Updates
sitemap.xmlwith blog post URLs
- Scans all
-
Build: React app is built with all blog posts
-
Post-build: react-snap pre-renders all blog pages for SEO
5. No Additional Configuration Needed
The blog system automatically:
- Generates URL-friendly slugs from titles
- Creates routes in your React app
- Updates the sitemap.xml
- Pre-renders pages for search engines
- Adds structured data (JSON-LD) for SEO
- Sets canonical URLs
Example Blog Post Structure
---
date: 2024-06-15
author: John Doe
featured: false
---
# **Your Awesome Blog Post Title**
## **An engaging subtitle that summarizes the post**
### Introduction
Your introduction paragraph here...
### Main Section
More content here...
## Conclusion
Wrap up your post...
### FAQ
#### Question 1?
Answer here...
SEO Best Practices
- Use descriptive titles: Make your H1 heading clear and descriptive
- Write compelling subtitles: The H2 will be used as the meta description
- Add dates: Always include a
datein frontmatter for accurate timestamps - Use alt text: Add descriptive alt text to all images
- Internal linking: Link to other relevant blog posts when appropriate
- Keep URLs clean: Titles should be concise to generate clean URL slugs
Metadata Configuration
For additional metadata not in frontmatter, you can edit blogPosts.js:
export const blogMetadata = {
'blog_005': {
coverImage: '/images/blog/awesome-post.jpg',
featured: true,
}
};
Frontmatter takes precedence over blogPosts.js metadata.
Testing Your Blog Post Locally
- Run
npm startto start the development server - Navigate to
/blogto see your post in the list - Click on your post to view it
- Check that all metadata is correct in browser dev tools:
- View Page Source to see meta tags
- Look for JSON-LD structured data in the
<head>
Production Deployment
Before deploying:
- Run
npm run buildto ensure everything compiles - Check
build/sitemap.xmlto verify your post is included - Verify pre-rendered HTML includes your content (check
build/blog/your-slug/index.html)
Common Issues
Q: My blog post isn't showing up
- Ensure the file ends with
.md - Check that it has a valid H1 heading (# Title)
- Run
npm run buildto regenerate routes
Q: The date is wrong
- Add
date: YYYY-MM-DDto frontmatter - Dates from frontmatter override file modification dates
Q: SEO not working
- Verify react-snap is running in postbuild
- Check that your title and subtitle are extracting correctly
- Use "View Page Source" (not inspect element) to see what search engines see
