For the complete documentation index, see llms.txt. This page is also available as Markdown.

Content configuration

Configure Git Sync through code

Git Sync uses three files. Choose the file that controls the part of Git Sync you need:

  • gitbook-docs.yaml configures the site and maps spaces to repository directories.

  • .gitbook.yaml configures how GitBook reads one space’s content.

  • SUMMARY.md defines a space’s navigation.

Configure the site with gitbook-docs.yaml

gitbook-docs.yaml configures the entire site. It lives in the Git Sync Project directory. GitBook uses the repository root when you don't set a Project directory.

Use gitbook-docs.yaml to define your site structure and map each space to a directory. Each item in site.structure has a stable key. A space’s content.directory sets its repository directory. If a space in a site does not sync to the site’s repository, its content.directory is null.

Keys identify your spaces

Git Sync recognizes each space and section by its key, not by its title, path, or directory. The key is how GitBook matches an entry in gitbook-docs.yaml to existing content from one sync to the next.

Keys are safe to choose freely when you first create an entry, and GitBook generates them for you when it saves the site content mapping. Once a space is live, treat its key as permanent:

  • To rename a space, change its title. The key stays the same.

  • To change a space’s URL, change its path. The key stays the same.

This example maps English and French spaces to separate directories:

Configure additional site properties

Use these optional properties to refine your site structure:

Property
Use it for

type: section-group

Group related sections under a shared navigation heading.

description

Add a description to a section.

icon

Add an icon to a section or section group.

localizedTitle

Translate a section, section group, or space title.

localizedDescription

Translate a section description.

hidden

Hide a space from site navigation.

GitBook creates or updates gitbook-docs.yaml when it saves the site content mapping.

Configure a space with .gitbook.yaml

.gitbook.yaml configures one space. It lives in that space’s mapped directory. Use it to set the content root, first page, navigation file, and redirects.

The main settings are:

  • root sets the directory GitBook reads. It defaults to ./.

  • structure.readme sets the first page. It defaults to README.md.

  • structure.summary sets the navigation file. It defaults to SUMMARY.md.

  • redirects maps old paths to new paths within the space.

Here is a typical configuration:

Set the content root

Set root when a space’s content lives inside a subdirectory:

In a monorepo, root only applies inside the mapped space directory. It doesn’t make sibling directories available. For multi-space repository setups, see Monorepos.

Set the first page and navigation file

Use structure.readme and structure.summary to set custom file paths:

Configure redirects

Configure space-level redirects in .gitbook.yaml. Redirect paths only apply within that space.

You can also manage site-level redirects in the GitBook app. See Site redirects.

Configure navigation with SUMMARY.md

SUMMARY.md defines a space’s table of contents. GitBook looks for it in the configured root directory.

If GitBook doesn't find SUMMARY.md, it infers navigation from your folders and Markdown files. GitBook creates or updates SUMMARY.md when you change navigation in GitBook.

Use headings for page groups and nested links for child pages:

Each Markdown file can appear once in SUMMARY.md. A page can only have one URL in a space.

Set navigation labels

Add a page link title when the navigation label differs from the page title:

GitBook uses the page link title in the sidebar, pagination, and relative links. Without one, GitBook uses the page title.

Last updated

Was this helpful?

Powered by GitBook