Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub


📝 Populate code blocks from files in a folder.

npm version

Starting from v1.0.0, the plugin is now ESM only. Node 12+ is needed to use it and it must be imported instead of required.


npm install -D remark-folder-import


The plugin can be imported via named export, there’s no default export.

import codeImport from 'remark-folder-import';

See Using plugins for more instructions in the official documentation.

It can also be used in various of libraries: remark: MDX, Gatsby gatsby-plugin-mdx, Storybook docs.



```js path=./Hello name=Hello



```js path=./Hello name=Hello
console.log('Hello remark-code-import!');

The file path is relative to the markdown file path. You can use <rootDir> at the start of the path to import files relatively from the rootDir:

```js path=<rootDir>/<path-to-file> name=<comman-file-name-to-import>



Shrey Dhyani MIT

© 2023 Gatsby, Inc.