Git CMS Configuration
Using files tracked with Git as a content source.
Netlify Create supports using files to store content (Git CMS). This guide covers what you need to know about configuring Netlify Create for a two-way data sync between Netlify Create and file-based content.
Example Configuration
Here is a simplified example that defines the following:
- A
page
model with a requiredtitle
field - Pages are stored in the
content
directory as JSON files - Assets are stored in the
public/images
directory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Prerequisites
The only thing required to work with Git CMS is to install the development dependencies.
1
Options
Git CMS is unique in that all content modeling must be done within content source configuration. The options to define the schema are shown below.
assetsConfig
Defines where local site assets are stored in your project, and how other content references these assets.
Static Assets
Here's an example configuration for this object using static assets from a public/images
directory.
1
2
3
4
5
6
7
8
9
10
11
12
13
- All assets must be placed under the directory set in
staticDir
, either directly or in subdirectories. They cannot be colocated with page content or source code. The value is always relative to the root of the project. - When the build is run, assets are served from the URL path set by
publicPath
. The full URLs are constructed as{publicPath}/{file path under staticDir}
. - With the example configuration above, an image file named
public/images/image.png
in your repository will be served from the URL/images/image.png
. - Images uploaded by editors would be saved in
{staticDir}/{uploadDir}
, or in the above case:{root}/public/images
.
Relative Assets
When asset files are colocated with content, use relative
references.
1
2
3
4
5
6
7
8
9
10
11
12
assetsDir
can include files of different types. However, only files with specific extensions will be treated as assets (png, jpg, jpeg, gif, svg, ico, etc.).- Images uploaded by editors would be saved in
{assetsDir}/{uploadDir}
, or in the above case:{root}/src/images
.
contentDirs
Defines directories in which to look for content. Each document is mapped to a model using the value of the type
property.
1
2
3
4
5
6
7
8
models
This is your schema definition for all file-based content.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
repoBranch
The Git branch used to read and write content.
This property is not used in local development, as content changes are written to disk and not committed or pushed to the remote repository.
1
2
3
4
5
6
7
8
repoUrl
URL to the remote Git repository used to read and write content.
This property is not used in local development, as content changes are written to disk and not committed or pushed to the remote repository.
1
2
3
4
5
6
7
8
rootPath
Absolute path to the root of your project. This is used to build relative paths for other configuration properties.
1
2
3
4
5
6
7
8
Annotations
When specifying object ID for annotations, most content sources will have an obvious ID value.
For Git CMS, this value is the path to the source file, relative to the root of the project, and including the file extension. For example, say a home page is located at content/pages/index.json
.
1
2
3
4
The ID value would be content/pages/index.json
.
1