The DocumentAssetsPlugin
is responsible for copying assets from a document sub-directory to the public folder of your site. This is particularly useful for co-locating images within your document structure and referencing them from documents using relative paths.
A common use case is to store images within the same directory structure as your documents. This allows you to reference images using relative paths.
For example, to load an image (mosaic.jpg
) from a sub-directory called images
, relative to the document's path, you can use the following Markdown:
This will render the image as follows:

Alternatively, if you prefer to store all your images in a common parent directory, you can reference them using a relative path that navigates up the directory structure.
For example, to load an image from a common parent directory, you can use:
The plugin ignores image paths that start with a leading slash (/) or are fully qualified URLs. This ensures that only relative paths are processed and copied to the public folder.
This plugin runs with a priority of -1 so it runs after most other plugins.
Property | Description | Default |
---|---|---|
srcDir | The path where pages reside after cloning or when running locally | './docs' |
outputDir | There path to your site's public images directory where you want to put the images | './public' |
assetSubDirs | An array of subdirectory globs that could contain assets | ['**/images'] |
imagesPrefix | The prefix that is added to all new paths | '/images' |
This plugin is not included in the mosaic config shipped by the Mosaic standard generator so it must be added manually to the plugins
collection: