How to Create and Publish Posts
Learn how to create, edit, and publish blog posts with proper frontmatter configuration
Introduction
This guide will walk you through the process of creating and publishing blog posts on this Astro-powered website. All posts are written in Markdown format and stored in the src/content/posts/ directory.
Creating a New Post
Step 1: Create a Markdown File
Navigate to the posts directory and create a new file:
cd src/content/posts
touch my-new-post.md
The filename will become the URL slug. For example:
my-new-post.md→/posts/my-new-posthello-world.md→/posts/hello-world
Use lowercase letters and hyphens for filenames. Avoid spaces and special characters!
Step 2: Add Frontmatter
Every post must start with frontmatter (metadata) enclosed in triple dashes:
***
title: "Your Post Title"
date: 2024-10-05
description: "A brief description of your post"
tags: ["tag1", "tag2", "tag3"]
draft: false
***
Frontmatter Fields Explained
Required Fields
| Field | Type | Description | Example |
|---|---|---|---|
title | string | Post title displayed in heading | "My Amazing Post" |
date | date | Publication date (YYYY-MM-DD) | 2024-10-05 |
Optional Fields
| Field | Type | Description | Default |
|---|---|---|---|
description | string | Short summary for SEO and previews | null |
tags | array | List of tags for categorization | [] |
draft | boolean | Hide post from production | false |
If draft: true, the post will not appear on the live website but will be visible in development mode.
Writing Content
After the frontmatter, write your content using Markdown syntax:
***
title: "My First Post"
date: 2024-10-05
description: "Learning to write blog posts"
tags: ["blogging", "tutorial"]
draft: false
***
## Introduction
Welcome to my first blog post!
### Section 1
Here's some content with **bold text** and *italic text*.
- List item 1
- List item 2
- List item 3
### Section 2
You can add code blocks:
\`\`\`javascript
console.log('Hello, World!');
\`\`\`
And images:
Markdown Features
Text Formatting
- Bold:
**bold text**or__bold text__ - Italic:
*italic text*or_italic text_ Strikethrough:~~strikethrough~~Inline code:`code`
Links
- External:
[Link text](https://example.com) - Internal:
[About page](/about)
Images
Place images in the public/images/ directory. They will be accessible at /images/filename.jpg.
Code Blocks
Use triple backticks with language specification:
\`\`\`javascript
function hello() {
console.log('Hello!');
}
\`\`\`
Supported languages include: javascript, typescript, python, bash, css, html, json, and many more!
Tables
| Column 1 | Column 2 | Column 3 |
|----------|----------|----------|
| Data 1 | Data 2 | Data 3 |
| Data 4 | Data 5 | Data 6 |
Publishing Your Post
Development Preview
- Start the dev server:
npm run dev
-
Navigate to
http://localhost:4321/posts/your-post-slug -
Check that everything looks correct
Deploy to Production
- Commit your changes:
git add src/content/posts/my-new-post.md
git commit -m "feat: add new blog post"
git push origin main
-
If using Vercel/Netlify, deployment happens automatically
-
Your post will be live in a few minutes!
Congratulations! Your post is now published and accessible to everyone.
Best Practices
Title Guidelines
- Keep titles under 60 characters for SEO
- Be descriptive and specific
- Use title case or sentence case consistently
- Avoid clickbait
Description Tips
- Write 120-160 characters for optimal SEO
- Include main keywords naturally
- Make it compelling but accurate
- Think of it as a preview snippet
Tag Management
- Use 3-5 tags per post
- Keep tags consistent across posts
- Use lowercase for tag names
- Choose relevant, searchable tags
Tags help readers discover related content and improve site navigation. Choose them wisely!
Troubleshooting
Post Not Showing Up?
- Check
draft: falsein frontmatter - Verify date is not in the future
- Ensure file is in
src/content/posts/directory - Rebuild the site:
npm run build
Formatting Issues?
- Validate frontmatter YAML syntax
- Check Markdown syntax errors
- Test locally before deploying
- View browser console for errors
Next Steps
Now that you know how to create posts, check out these guides:
- Admonitions Guide - Learn to use callout boxes
- Google Verification - Set up Google Search Console
- Installation Guide - Full setup documentation
Happy blogging! 🚀
Comments
Comments are moderated and will be approved shortly.
Loading comments...
No comments yet. Be the first to comment!
Leave a comment
Insert GIF URL
Paste direct GIF URL from Giphy, Tenor, or any GIF site
Preview: