#Import content from one markdown file into another

3 messages · Page 1 of 1 (latest)

steel sierra
#

How would I import a section of text from one markdown or mdx file into another?

graceful coveBOT
#

Hi @steel sierra. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

To import a section of text from one Markdown or MDX file into another, you can use the import statement in Astro. Here's an example of how to import a specific Markdown file:

---
// Import a single file
import * as myPost from '../pages/post/my-post.md';
---

For MDX files, you can import and use components just as you would in any other Astro component:

---
layout: ../layouts/BaseLayout.astro
title: About me
---
import Button from '../components/Button.astro';
import ReactCounter from '../components/ReactCounter.jsx';

However, importing a specific section of text is not directly supported. You would need to structure your content in a way that allows you to import the desired section as a separate component or file.

For more information on importing Markdown and MDX files, refer to the Astro documentation on Importing Markdown (https://docs.astro.build/en/guides/markdown-content#importing-markdown).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

Astro Documentation

Learn how to create content using Markdown or MDX with Astro