# gatsby-plugin-netlify-cms

> A Gatsby plugin which generates the Netlify CMS single page app

Latest version **7.12.1** (published 2023-12-14) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install gatsby-plugin-netlify-cms
pnpm add gatsby-plugin-netlify-cms
yarn add gatsby-plugin-netlify-cms
bun add gatsby-plugin-netlify-cms
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 7.12.1 |
| Published | 2023-12-14 |
| First published | 2018-01-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18.0.0 |
| Dependencies | 9 |
| Unpacked size | 78.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 55919 |
| Author | Shawn Erquhart |
| Maintainers | kathmbeck, pieh, tylerbarnes, fk, daniellewgatsby, kylemathews, freiksenet, dschau, wardpeet, erquhart, m-allanson, sidharthachatterjee, moocar |
| Keywords | gatsby, gatsby-plugin, netlify, netlify-cms, cms |

## Links

- npm: https://www.npmjs.com/package/gatsby-plugin-netlify-cms
- Repository: https://github.com/gatsbyjs/gatsby
- Homepage: https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-netlify-cms#readme
- Issues: https://github.com/gatsbyjs/gatsby/issues
- npm.io page: https://npm.io/package/gatsby-plugin-netlify-cms

## Dependencies (9)

- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.20.13
- [copy-webpack-plugin](https://npm.io/package/copy-webpack-plugin.md) ^7.0.0
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^5.5.3
- [mini-css-extract-plugin](https://npm.io/package/mini-css-extract-plugin.md) 1.6.2
- [netlify-identity-widget](https://npm.io/package/netlify-identity-widget.md) ^1.9.2
- [html-webpack-tags-plugin](https://npm.io/package/html-webpack-tags-plugin.md) ^3.0.2
- [html-webpack-skip-assets-plugin](https://npm.io/package/html-webpack-skip-assets-plugin.md) ^1.0.3
- [@soda/friendly-errors-webpack-plugin](https://npm.io/package/@soda/friendly-errors-webpack-plugin.md) 1.8.1

## Recent versions

- 7.12.1 (latest) — 2023-12-14
- 7.13.0-next.0 (next) — 2023-07-25
- 5.15.0 (latest-v3) — 2022-12-07
- 6.25.0 (latest-v4) — 2022-12-07
- 7.0.0-alpha-drupal-proxyurl.14 (drupal-proxyurl) — 2022-11-22
- 6.14.0-alpha-transformer-json.26 (alpha-transformer-json) — 2022-10-12
- 7.0.0-alpha-v5.d20221012t101120.57 (alpha-v5) — 2022-10-12
- 6.23.0-alpha-a5-peer.70 (alpha-a5-peer) — 2022-09-14
- 6.23.0-alpha-preview-gh-api.26 (preview-gh-api) — 2022-09-08
- 6.23.0-alpha-9689ff.25 (alpha-9689ff) — 2022-08-31
- 6.18.0-alpha-drupal-self-reference.18 (drupal-self-reference) — 2022-07-19
- 6.17.0-alpha-gatsby-metadata.60 (alpha-gatsby-metadata) — 2022-07-13
- 6.15.0-alpha-wp-image-cdn-auth.48 (wp-image-cdn-auth) — 2022-05-20
- 6.8.0-alpha-image-service.24 (image-service) — 2022-02-10
- 6.6.0-alpha-ts-jit.60 (alpha-ts-jit) — 2022-01-21
- … 374 more at https://npm.io/package/gatsby-plugin-netlify-cms/versions

## README

## ⚠️ This package is now deprecated

The `gatsby-plugin-netlify-cms` package is now deprecated. This plugin has been renamed and moved to [Decap CMS](https://github.com/decaporg/gatsby-plugin-decap-cms). See [gatsby-plugin-decap-cms](https://www.npmjs.com/package/gatsby-plugin-decap-cms) for more information.

# gatsby-plugin-netlify-cms

**Gatsby v1 and Netlify CMS 1.x require [`gatsby-plugin-netlify-cms@^2.0.0`][1].**

**Gatsby v2 and Netlify CMS 2.x require [`gatsby-plugin-netlify-cms@^3.0.0`][2].**

**Gatsby v2 and Netlify CMS (netlify-cms-app) 2.9.x required `gatsby-plugin-netlify-cms@^4.0.0`, which is documented below.**

## Overview

Automatically generates an `admin/index.html` with a default Netlify CMS implementation.

Netlify CMS is a React single page app for editing git based content via API.
Its built for non-technical and technical editors alike, and its super easy to
install and configure. For more details, check out the [docs
site](https://netlifycms.org).

**Note:** `gatsby-plugin-netlify-cms@^4.0.0` changes the requirement for Netlify CMS to use a new library published `netlify-cms-app@^2.9.x` and is a **breaking change**.

## Install

```shell
npm install netlify-cms-app gatsby-plugin-netlify-cms
```

## How to use

Add the Netlify CMS plugin in your `gatsby-config.js`:

```javascript
plugins: [`gatsby-plugin-netlify-cms`]
```

Then add your Netlify CMS [configuration
file](https://www.netlifycms.org/docs/add-to-your-site/#configuration) in
`static/admin/config.yml`.

## Options

Netlify CMS can be configured via the plugin options below. You can learn
about how to pass options to plugins in the [Gatsby
docs](https://www.gatsbyjs.com/docs/plugins/#how-to-use-gatsby-plugins).

### `modulePath`

(_optional_, type: `string | Array<string>`, default: `undefined`)

If you need to customize Netlify CMS, e.g. registering [custom
widgets](https://www.netlifycms.org/docs/custom-widgets/#registerwidget) or
styling the [preview
pane](https://www.netlifycms.org/docs/customization/#registerpreviewstyle),
you'll need to do so in a JavaScript module and provide Gatsby with the path to
your module via the `modulePath` option. Any styles imported by this module (or
by the modules that it imports, all the way down the chain) are automatically
applied to the editor preview pane by the plugin.

```javascript
plugins: [
  {
    resolve: `gatsby-plugin-netlify-cms`,
    options: {
      /**
       * One convention is to place your Netlify CMS customization code in a
       * `src/cms` directory.
       */
      modulePath: `${__dirname}/src/cms/cms.js`,
    },
  },
]
```

The js module might look like this:

```javascript
/**
 * The default export of `netlify-cms-app` is an object with all of the Netlify CMS
 * extension registration methods, such as `registerWidget` and
 * `registerPreviewTemplate`.
 */
import CMS from "netlify-cms-app"

/**
 * Any imported styles should be automatically be applied to the editor preview
 * pane thus eliminating the need to use `registerPreviewStyle` for imported
 * styles. However if you are experiencing build errors regarding importing css,
 * sass or scss into a cms module when deploying to the netlify platform, you
 * may need to follow the implementation found in netlify documentation here:
 * https://www.netlifycms.org/docs/beta-features/#raw-css-in-registerpreviewstyle
 * All of the example imports below would result in styles being applied to the
 * preview pane.
 */
import "module-that-imports-styles.js"
import "styles.scss"
import "../other-styles.css"

/**
 * Let's say you've created widget and preview components for a custom image
 * gallery widget in separate files:
 */
import ImageGalleryWidget from "./image-gallery-widget.js"
import ImageGalleryPreview from "./image-gallery-preview.js"

/**
 * Register the imported widget:
 */
CMS.registerWidget(`image-gallery`, ImageGalleryWidget, ImageGalleryPreview)
```

### `manualInit`

(_optional_, type: `boolean`, default: `false`)

Set this to `true` If you need to [manually initialize](https://www.netlifycms.org/docs/beta-features/#manual-initialization) Netlify CMS. The plugin will take care of setting `window.CMS_MANUAL_INIT` to `true`:

```javascript
plugins: [
  {
    resolve: `gatsby-plugin-netlify-cms`,
    options: {
      manualInit: true,
    },
  },
]
```

The js module might look like this:

```javascript
import CMS from "netlify-cms-app"

/**
 * Optionally pass in a config object. This object will be merged into `config.yml` if it exists
 */

CMS.init({
  config: {
    backend: {
      name: "git-gateway",
    },
  },
})
```

### `enableIdentityWidget`

(_optional_, type: `boolean`, default: `true`)

`enableIdentityWidget` is `true` by default, allowing [Netlify
Identity](https://www.netlify.com/docs/identity/) to be used without
configuration. Disable it when not using Netlify Identity to reduce bundle size.

```javascript
plugins: [
  {
    resolve: `gatsby-plugin-netlify-cms`,
    options: {
      enableIdentityWidget: true,
    },
  },
]
```

### `publicPath`

(_optional_, type: `string`, default: `"admin"`)

Customize the path to Netlify CMS on your Gatsby site.

### `htmlTitle`

(_optional_, type: `string`, default: `Content Manager`)

Customize the value of the `title` tag in your CMS HTML (shows in the browser
bar).

### `htmlFavicon`

(_optional_, type: `string`, default: `""`)

Customize the value of the `favicon` tag in your CMS HTML (shows in the browser
bar).

### `includeRobots`

(_optional_, type: `boolean`, default: `false`)

By default, the CMS page is not indexed by crawlers. Use this to add a `meta` tag to invite robots to index the CMS page.

### `customizeWebpackConfig`

(_optional_, type: `function`)

Function to customize webpack configuration.

Function parameters:

- config: webpack configuration for NetlifyCMS
- destructured object from onCreateWebpackConfig { store, stage, pathPrefix, getConfig, rules, loaders, plugins} as seen in https://www.gatsbyjs.com/docs/node-apis/#onCreateWebpackConfig

```javascript
plugins: [
  {
    resolve: `gatsby-plugin-netlify-cms`,
    options: {
      customizeWebpackConfig: (config, { plugins }) => {
        const Plugin = require("...")

        config.plugins.push(
          plugins.define({
            "process.env.MY_VAR": JSON.stringify("my var value"),
          })
        )

        config.plugins.push(new Plugin())
      },
    },
  },
]
```

## Example

Here is the plugin with example values for all options (note that no option is
required):

```javascript
plugins: [
  {
    resolve: `gatsby-plugin-netlify-cms`,
    options: {
      modulePath: `path/to/custom/script.js`, // default: undefined
      enableIdentityWidget: true,
      publicPath: `admin`,
      htmlTitle: `Content Manager`,
      htmlFavicon: `path/to/favicon`,
      includeRobots: false,
    },
  },
]
```

## Disable widget on site

If you're not using Netlify Identity within your site you have the option to completely disable the widget (and not the CMS). To do so, add the following to `gatsby-node.js`:

```javascript
const webpack = require(`webpack`)

exports.onCreateWebpackConfig = ({ actions }) => {
  actions.setWebpackConfig({
    plugins: [
      new webpack.IgnorePlugin({
        resourceRegExp: /^netlify-identity-widget$/,
      }),
    ],
  })
}
```

## Support

For help with integrating Netlify CMS with Gatsby, check out the community
[Slack](https://www.netlifycms.org/chat).

[1]: https://github.com/gatsbyjs/gatsby/blob/gatsby-plugin-netlify-cms@2.0.1/packages/gatsby-plugin-netlify-cms/README.md
[2]: https://github.com/gatsbyjs/gatsby/blob/gatsby-plugin-netlify-cms@3.0.18/packages/gatsby-plugin-netlify-cms/README.md

---
_Source: https://npm.io/package/gatsby-plugin-netlify-cms · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
