Astro content collections in external directories with symlinks
1 min read
·
Published on
·
Updated on
EasyABC is a no-code blog template. Asking people to browser the src
dir is contrary to this goal.
However, Astro requires content collections to live in the src/content
dir.
There is an easy resolution to this using symlinks. If you’re familiar with Microsoft Window’s shortcuts, you’re already familar with the concept of a *nix symlink.
First, add this to your Astro config.
export default defineConfig({
vite: {
resolve: {
preserveSymlinks: true,
},
},
});
Then in the terminal:
ln -s path/content-collection src/content
In the case of EasyABC it was:
ln -s public/personal-blog/blog src/content
Thanks to Elio Struyf for his detailed explanation on this topic!