Prerequisites
Before creating a blog post, make sure you understand:- Content Collections - The schema and validation system
- Blog System Architecture - How posts are rendered
Creating a New Post
Create the file
Create a new The filename will become the URL slug:
.md file in src/content/blog/ with a URL-friendly name:/blog/my-awesome-postAdd frontmatter
Add the required frontmatter fields at the top of the file:
The
createdAt field must be in ISO 8601 format. Generate it using new Date().toISOString() in JavaScript or use an online tool.Write your content
Write your blog post content using standard Markdown below the frontmatter:You can use:
- Headings (
#,##,###) - Lists (ordered and unordered)
- Links (
[text](url)) - Images (
) - Code blocks with syntax highlighting
- Blockquotes
- Bold and italic text
Preview your post
Start the development server to preview your post:Navigate to
http://localhost:4321/blog/your-post-slug to see your post.Real Example
Here’s a complete example from the project -guide-to-geometry-dash.md:
/blog/guide-to-geometry-dash with:
- Author card showing “Ivanciooo” with avatar
- Three tags: Guide, Beginners, Tutorials
- Cover image from the
imagefield - Publication date displayed as “August 12, 2025”
Frontmatter Field Reference
title
Type:string (required)
The post title displayed in:
- The page
<title>tag - The main heading on the post page
- Post cards on the blog listing page
createdAt
Type:string (required, datetime)
ISO 8601 datetime when the post was created. Used for:
- Sorting posts by date
- Displaying publication date
- Calculating “X days ago” text
updatedAt
Type:string (optional, datetime)
ISO 8601 datetime when the post was last updated.
image
Type:string (required)
URL to the cover image. Displayed:
- As a large hero image on the post page
- As a thumbnail in post cards
- In social media previews (Open Graph)
description
Type:string (required)
Brief description of the post. Used for:
- SEO meta descriptions
- Social media previews
- Post card previews
author
Type:string (required)
Author’s name, displayed in the author card on the post page.
publish
Type:boolean (required)
Whether the post should be published. Set to false for drafts.
You need to manually filter by
publish: true in your queries if you want to hide unpublished posts.tags
Type:string[] (optional)
Array of tags/categories for the post. Displayed as badges on the post page.
authorImage
Type:string (required)
URL to the author’s avatar image, displayed in the author card.
Markdown Styling
ThePostLayout component provides custom styling for markdown content:
- Headings - Bold, white text with proper sizing
- Paragraphs - 1.1rem font size with 1.75 line height
- Lists - Proper spacing and indentation
- Links - Primary color (#0281C6) with hover effects
- Images - Rounded corners, responsive sizing
- Blockquotes - Left border in primary color
- Code - Dark background with syntax highlighting
src/pages/blog/[slug].astro:178-293.
Best Practices
Next Steps
- Blog System Overview - Understand how posts are rendered
- Content Collections - Learn about the schema and validation
