Tillitsdone
down Scroll to discover

Using Markdown in Astro.js Projects

Learn how to effectively use Markdown in your Astro.js projects.

Discover features like frontmatter support, MDX integration, automatic slug generation, and best practices for content management.
thumbnail

Abstract geometric pattern with layers of curved lines and shapes dominated by bright zinc and white colors creating a flowing modern composition shot from top-down perspective high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

Using Markdown in Astro.js Projects

One of the things I absolutely love about Astro.js is how seamlessly it handles Markdown content. Whether you’re building a blog, documentation site, or content-heavy platform, Astro’s Markdown integration makes content management a breeze. Let me walk you through everything you need to know about using Markdown in your Astro projects.

Getting Started with Markdown in Astro

Right out of the box, Astro supports Markdown files with the .md extension. You don’t need any additional configuration to start using them. Just create a new file in your src/pages directory with a .md extension, and Astro automatically transforms it into a static HTML page.

Modern minimalist interior space with clean lines and geometric shapes featuring warm clay and white tones natural light streaming through large windows captured from a wide-angle perspective high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

Enhanced Markdown with MDX

Want to take your Markdown to the next level? Astro also supports MDX, which lets you include JavaScript expressions and React components directly in your Markdown files. To use MDX, you’ll need to install the MDX integration:

Terminal window
npm install @astrojs/mdx

After installation, update your astro.config.mjs:

import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
export default defineConfig({
integrations: [mdx()],
});

Markdown Features You’ll Love

Astro’s Markdown support includes all the features you’d expect, plus some excellent extras:

Frontmatter Support

Every Markdown file can include frontmatter - metadata about your content wrapped in triple-dashes. This is perfect for adding titles, descriptions, dates, or any custom data your content needs.

Automatic Slug Generation

Astro automatically creates URL-friendly slugs from your Markdown filenames. A file named hello-world.md becomes available at /hello-world in your built site.

Rocky coastal landscape with dramatic cliffs meeting the ocean dominated by navy blue water and white foam waves captured during golden hour from a dramatic elevated angle high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

Code Syntax Highlighting

Code blocks in your Markdown files get automatic syntax highlighting. Astro uses Shiki by default, which provides beautiful, accurate highlighting for hundreds of programming languages.

Best Practices

Here are some tips I’ve learned while working with Markdown in Astro:

  1. Organize your content in a dedicated directory (like src/content) to keep things tidy
  2. Use consistent frontmatter schemas across similar content types
  3. Take advantage of Astro’s content collections for better type safety and organization
  4. Keep your images in an organized structure relative to your content

What’s Next?

Once you’ve mastered the basics, you can explore more advanced features like custom components in MDX, dynamic content generation, and integrating with headless CMS platforms. The possibilities are endless!

Textured abstract background with overlapping geometric shapes and lines featuring bright rose and zinc colors creating a modern pattern photographed from a straight-on perspective high-quality ultra-realistic cinematic 8K UHD high resolution sharp and detail

icons/code-outline.svg AstroJs Blogs
Astro is an all-in-one web framework. It includes everything you need to create a website, built-in.
icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐️ Contact us
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.