|
| 1 | +--- |
| 2 | +title: Markdown |
| 3 | +disableTableOfContents: true |
| 4 | +--- |
| 5 | + |
| 6 | +Learn what Markdown is, why you might use it, and how it fits into the Gatsby ecosystem. |
| 7 | + |
| 8 | +## What is Markdown? |
| 9 | + |
| 10 | +Markdown is a plain text syntax for writing text documents that can be transformed to HTML. Markdown uses punctuation characters to indicate HTML elements. That punctuation then gets converted to HTML tags during a transformation or export process. |
| 11 | + |
| 12 | +Markdown dates back to 2004, when John Gruber published the original [Markdown syntax guide](https://daringfireball.net/projects/markdown/syntax). Gruber, along with Aaron Swartz, created Markdown with two goals: |
| 13 | + |
| 14 | +1. to make Markdown <q>as easy-to-read and easy-to-write as is feasible.</q>; and |
| 15 | +1. to support inline HTML within Markdown-formatted text. |
| 16 | + |
| 17 | +Text-to-HTML filters such as [Textile](https://textile-lang.com/) define a syntax that replaces a wide range of HTML elements. Other filters, such as [reStructuredText](https://docutils.readthedocs.io/en/sphinx-docs/user/rst/quickstart.html), do not support inline HTML tags. |
| 18 | + |
| 19 | +Markdown, by contrast, only defines a syntax for a small subset of HTML elements. For other elements, you use the corresponding HTML tag. In other words, Markdown makes it possible to write documents without knowing HTML, but HTML is available if you need it. A Markdown document might look like the example that follows. |
| 20 | + |
| 21 | +```markdown |
| 22 | +# Markdown! |
| 23 | + |
| 24 | +You can use Markdown to create documents for [Gatsby](https://www.gatsbyjs.org/). |
| 25 | + |
| 26 | +<figure class="chart"> |
| 27 | + <object data="chart.svg" type="image/svg+xml"></object> |
| 28 | + <figcaption> |
| 29 | + Developers who love using Gatsby versus those who haven't tried it yet. |
| 30 | + </figcaption> |
| 31 | +</figure> |
| 32 | +``` |
| 33 | + |
| 34 | +When converted to HTML, the preceding Markdown will become the markup below. |
| 35 | + |
| 36 | +```html |
| 37 | +<h1>Markdown!</h1> |
| 38 | +<p> |
| 39 | + You can use Markdown to create documents for |
| 40 | + <a href="https://www.gatsbyjs.org/">Gatsby</a>. |
| 41 | +</p> |
| 42 | +<figure class="chart"> |
| 43 | + <object data="chart.svg" type="image/svg+xml"></object> |
| 44 | + <figcaption> |
| 45 | + Developers who love using Gatsby versus those who haven't tried it yet. |
| 46 | + </figcaption> |
| 47 | +</figure> |
| 48 | +``` |
| 49 | + |
| 50 | +You can use Markdown files as a content source for your Gatsby site. To do so, you'll need to install two plugins: [`gatsby-source-filesystem`](/packages/gatsby-source-filesystem) and [`gatsby-transformer-remark`](/packages/gatsby-transformer-remark/). As with Gatsby itself, you can install both using [npm](/docs/glossary/#npm). |
| 51 | + |
| 52 | +```bash |
| 53 | +npm install --save gatsby-source-filesystem gatsby-transformer-remark |
| 54 | +``` |
| 55 | + |
| 56 | +The `gatsby-source-filesystem` plugin reads files from your computer. The `gatsby-transformer-remark` plugin makes the contents of your Markdown files available to GraphQL. |
| 57 | + |
| 58 | +You can also try a [Gatsby starter](https://www.gatsbyjs.org/starters/?c=Markdown) package that has Markdown support already included. |
| 59 | + |
| 60 | +## Learn more about Markdown |
| 61 | + |
| 62 | +- [Markdown syntax](/docs/mdx/markdown-syntax/) from the Gatsby docs |
| 63 | +- [CommonMark](https://commonmark.org/), a proposed Markdown specification |
| 64 | +- [Sourcing from the Filesystem](/docs/sourcing-from-the-filesystem/) from the Gatsby docs |
| 65 | +- [Adding Markdown Pages](/docs/adding-markdown-pages/) from the Gatsby docs |
0 commit comments