Using Markdown for Storing Data

Learn how we can store and retrieve data in Astro using Markdown files.

When building content-based web applications, data storage becomes a crucial part of a project. There are many different ways to store data for web applications. Most commonly, a server is used with a database that can be reached through the use of an API.

However, this requires a complete back-end infrastructure, which is overkill for simple projects, especially for most pages that are using SSG as their main rendering strategy. Instead, we can store information in local files that help us manage both code and content in one place. To achieve this, we’ll use Markdown for data storage.

Markdown

Markdown is a lightweight markup language that can be used for formatting text. We can think of it as a simplified version of HTML. So, why use a different formatting instead of using HTML files? There are a couple of advantages of Markdown files over HTML. These are given below:

  • Versatility: It can be used in other areas where HTML cannot be used—for example, in books, emails, or presentations.

  • Simplicity: It’s beginner-friendly. It can also be used by nontechnical people because Markdown syntax is easier to remember and write, compared to complex HTML layouts.

Let’s take a look at a couple of commonly used Markdown syntax:

Element

Markdown Syntax

Heading

# H1

## H2

### H3

Italic

*This text will be italic*

Bold

**This text will be bold**

Ordered List

  • Ordered
  • List

Unordered List

  • Unordered
  • List

Horizontal Rule

---

Link

[This will be linked to Google](https://google.com)

Creating Markdown data files

The best way to manage content in Astro is to use the content ...