2019-10-26 04:10:48 -04:00
---
id: presets
title: Presets
---
Presets are collections of plugins and themes.
2020-05-17 23:37:53 -04:00
## Using presets
2019-10-26 04:10:48 -04:00
A preset is usually a npm package, so you install them like other npm packages using npm.
2019-11-23 21:32:26 -05:00
```bash npm2yarn
2019-10-26 04:10:48 -04:00
npm install --save docusaurus-preset-name
```
Then, add it in your site's `docusaurus.config.js` 's `presets` option:
2020-03-28 13:08:50 -04:00
```jsx {3} title="docusaurus.config.js"
2019-10-26 04:10:48 -04:00
module.exports = {
2019-10-29 02:59:24 -04:00
// ...
2019-10-26 04:10:48 -04:00
presets: ['@docusaurus/preset-xxxx'],
};
```
To load presets from your local directory, specify how to resolve them:
2020-03-28 13:08:50 -04:00
```jsx {5} title="docusaurus.config.js"
2019-10-26 04:10:48 -04:00
const path = require('path');
module.exports = {
2019-10-29 02:59:24 -04:00
// ...
2019-10-26 04:10:48 -04:00
presets: [path.resolve(__dirname, '/path/to/docusaurus-local-presets')],
};
```
2020-05-17 23:37:53 -04:00
## Presets -> themes and plugins
2019-10-26 04:10:48 -04:00
Presets in some way are a shorthand function to add plugins and themes to your docusaurus config. For example, you can specify a preset that includes the following themes and plugins,
```js
module.exports = function preset(context, opts = {}) {
return {
2020-05-22 16:57:02 -04:00
themes: [
require.resolve('@docusaurus/themes-cool'),
require.resolve('@docusaurus/themes-bootstrap'),
],
plugins: [require.resolve('@docusaurus/plugin-blog')],
2019-10-26 04:10:48 -04:00
};
};
```
then in your Docusaurus config, you may configure the preset instead:
2020-03-28 13:08:50 -04:00
```jsx {3} title="docusaurus.config.js"
2019-10-26 04:10:48 -04:00
module.exports = {
2019-10-29 02:59:24 -04:00
// ...
2020-03-28 13:08:50 -04:00
presets: ['@docusaurus/preset-my-own'],
2019-10-26 04:10:48 -04:00
};
```
This is equivalent of doing:
2020-03-28 13:08:50 -04:00
```jsx title="docusaurus.config.js"
2019-10-26 04:10:48 -04:00
module.exports = {
themes: ['@docusaurus/themes-cool', '@docusaurus/themes-bootstrap'],
plugins: ['@docusaurus/plugin-blog'],
};
```
This is especially useful when some plugins and themes are intended to be used together.
2020-05-17 23:37:53 -04:00
## Official presets
2019-10-26 04:10:48 -04:00
### `@docusaurus/preset-classic`
The classic preset that is usually shipped by default to new docusaurus website. It is a set of plugins and themes.
2020-04-04 02:05:59 -04:00
| Themes | Plugins |
| ---------------------------------- | ------------------------------------- |
| `@docusaurus/theme-classic` | `@docusaurus/plugin-content-docs` |
| `@docusaurus/theme-search-algolia` | `@docusaurus/plugin-content-blog` |
| | `@docusaurus/plugin-content-pages` |
| | `@docusaurus/plugin-google-analytics` |
| | `@docusaurus/plugin-google-gtag` |
| | `@docusaurus/plugin-sitemap` |
2019-10-26 04:10:48 -04:00
2019-11-01 20:12:04 -04:00
To specify plugin options individually, you can provide the necessary fields to certain plugins, i.e. `customCss` for `@docusaurus/theme-classic` , pass them in the preset field, like this:
2019-10-26 04:10:48 -04:00
2020-03-28 13:08:50 -04:00
```js title="docusaurus.config.js"
2019-10-26 04:10:48 -04:00
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
// Will be passed to @docusaurus/theme -classic.
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
// Will be passed to @docusaurus/plugin -content-docs
docs: {},
// Will be passed to @docusaurus/plugin -content-blog
blog: {},
// Will be passed to @docusaurus/plugin -content-pages
pages: {},
// Will be passed to @docusaurus/plugin -content-sitemap
sitemap: {},
},
],
],
};
```
2020-02-08 06:28:47 -05:00
In addition to these plugins and themes, `@docusaurus/theme-classic` adds [`remark-admonitions` ](https://github.com/elviswolcott/remark-admonitions ) as a remark plugin to `@docusaurus/plugin-content-blog` and `@docusaurus/plugin-content-docs` .
The `admonitions` key will be passed as the [options ](https://github.com/elviswolcott/remark-admonitions#options ) to `remark-admonitions` . Passing `false` will prevent the plugin from being added to MDX.
2020-03-28 13:08:50 -04:00
```js title="docusaurus.config.js"
2020-02-08 06:28:47 -05:00
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
// options for remark-admonitions
admonitions: {},
},
},
],
],
};
```
2020-08-17 14:18:37 -04:00
### `@docusaurus/preset-bootstrap`
The classic preset that is usually shipped by default to new docusaurus website. It is a set of plugins and themes.
| Themes | Plugins |
| ---------------------------------- | ------------------------------------- |
| `@docusaurus/theme-bootstrap` | `@docusaurus/plugin-content-docs` |
| | `@docusaurus/plugin-content-blog` |
| | `@docusaurus/plugin-content-pages` |
To specify plugin options individually, you can provide the necessary fields to certain plugins, i.e. `docs` for `@docusaurus/theme-bootstrap` , pass them in the preset field, like this:
```js title="docusaurus.config.js"
module.exports = {
presets: [
[
'@docusaurus/preset-bootstrap',
{
// Will be passed to @docusaurus/plugin -content-docs
docs: {},
// Will be passed to @docusaurus/plugin -content-blog
blog: {},
},
],
],
};
```
:::caution
This preset is work in progress
:::
2019-10-26 04:10:48 -04:00
<!--
Advanced guide on using and configuring presets
References
---
- [classic themes ](/packages/docusaurus-preset-classic/src/index.js )
- [babel docs on presets ](https://babeljs.io/docs/en/presets )
-->