Authoring Content

view of white metal tower through cherry blossom tree

Astro is a perfect choice for your content-focused site: blogs, marketing sites, portfolios, and more!

Astro helps you author and present your content. You can write a blog post directly in Astro using Markdown/MDX, or fetch your content from a headless CMS. Astro lets you build a site around your content: you can add a layout to your pages, create an index of posts, and set up an RSS feed to allow readers to subscribe.

Writing Content

Section titled Writing Content In Astro, you can author your content in a variety of ways:

Markdown Authoring

Section titled Markdown Authoring Markdown is a convenient syntax for writing rich text with basic formatting and common elements like headers, lists, and images. Astro has built-in support for Markdown files in your project.

Create and write a new .md file in your code editor or bring in an existing file written in your favorite Markdown editor. Some online Markdown editors like StackEdit and Dillinger will even allow you to edit and sync your work with your Astro repository stored on GitHub.

Learn more about writing Markdown content in Astro.

MDX Authoring

Section titled MDX Authoring If you add the Astro MDX integration to your project, you can also write content using .mdx files, which can include JavaScript expressions and components within your Markdown. This includes both static Astro components and interactive framework components. This allows you to include UI elements such as a banner or an interactive carousel along with your text content.

Write and edit .mdx files directly in your code editor, alongside your project files. MDX files are a supported page file type in Astro, and may also be used as content collection entries.

Learn more about using MDX with Astro.

Headless CMS Authoring

Section titled Headless CMS Authoring Write blog posts in your existing Content Management System (CMS) such as Storyblok, WordPress, or Contentful. Some CMSes, like Storyblok, provide an official Astro integration. Others expose a JavaScript SDK that Astro pages can use to fetch your remote content.

Explore our collection of CMS guides and Astro CMS integrations for a wide selection of resources.

Managing content pages

Section titled Managing content pages

Page files

Section titled Page files Markdown and MDX files that live in your src/pages directory will automatically generate pages on your site using Astro’s file-based routing, built at a URL corresponding to the post’s file path.

Local content

Section titled Local content You can also choose to keep your Markdown and MDX files outside of the src/pages directory, and instead import their content into .astro pages.

Content collections

Section titled Content collections Astro’s own content collections provide a powerful, type-safe way to work with Markdown, MDX, or Markdoc content organized in the src/content/ directory.

Remote content

Section titled Remote content You can also fetch markdown remotely from a source outside of your project. This will require your own Markdown parser, or a community integration (e.g. astro-remote).

Showcasing your content

Section titled Showcasing your content To build common features to organize and display your content, such as a blog archive or a page for each blog tag, Astro allows you to fetch filenames and metadata from your Markdown and MDX frontmatter or use content collection helper utilities to query your entries and generate page content and routes.

To publish to a broader audience, create an RSS feed that can be distributed to feed readers.

Community Integrations

Section titled Community Integrations In addition to the official @astrojs/mdx and @astrojs/markdoc integrations, there are several third-party community integrations for working with content in your Astro project.

Learn

Publish on 2024-01-31,Update on 2024-11-06