skill
Edit and manage GitBook documentation
A comprehensive guide for editing GitBook documentation in external environments like Cursor, Claude Code, or other text editors. This skill provides all the formatting syntax, configuration options, and best practices needed to create and maintain GitBook content outside the GitBook web interface.
When to Use This Skill
Use this skill when working with GitBook documentation through:
Git-synced repositories (GitHub, GitLab)
Local markdown editors
IDE integrations
Command-line tools
Any environment where you're editing GitBook content as files rather than through the GitBook UI
Quick Reference
GitBook Content Structure
GitBook organizes content through pages, spaces, and collections:
Pages are individual markdown files that make up your documentation
Spaces are collections of pages organized into a documentation site
Collections are groups of spaces
File structure:
/
.gitbook/
assets/ # GitBook-managed images and files
includes/ # Reusable content blocks
vars.yaml # Space-level variables
.gitbook.yaml # Configuration
README.md # Homepage
SUMMARY.md # Table of contents
getting-started/ # Section folder
installation.md
quickstart.md
api-reference/
authentication.md
endpoints.mdFrontmatter fields:
Variables and expressions:
Space variables:
/.gitbook/vars.yamlPage variables: Frontmatter
vars:Expression syntax:
<code class="expression">space.vars.variableName</code>
Most common custom blocks:
<div data-gb-custom-block data-tag="tabs">...</div>for alternatives<div data-gb-custom-block data-tag="hint" data-style='...'>...</div>for callouts<div data-gb-custom-block data-tag="stepper">...</div>for sequential steps<details>...<summary>...</details>for expandable content
Links:
External:
[text](https://example.com)Internal: Use relative paths like
[text](page.md)or[text](../folder/page.md)
Key reminders:
Read SUMMARY.md first when working with existing content to understand structure
Test in GitBook after editing locally
Keep SUMMARY.md synchronized with your file structure
Variables are defined in
.gitbook/vars.yaml(space-level) or page frontmatter (page-level)OpenAPI specs must be uploaded via API/CLI/UI, not embedded in markdown
When to Use Which Block
Choose the right GitBook block for your content needs:
Sequential, ordered instructions
<div data-gb-custom-block data-tag="stepper"></div>
Guides users through multi-step processes with clear progression
Alternative options (languages, platforms)
<div data-gb-custom-block data-tag="tabs"></div>
Lets users choose their relevant option without cluttering the page
Optional or detailed information
<details> (Expandable)
Keeps page scannable while providing depth for interested readers
Important warnings or tips
<div data-gb-custom-block data-tag="hint"></div>
Draws attention with colored styling (info, warning, danger, success)
Side-by-side comparisons
<div data-gb-custom-block data-tag="columns"></div>
Shows related information in parallel (max 2 columns)
Timeline or changelog
<div data-gb-custom-block data-tag="updates"></div>
Displays dated entries in reverse chronological order
Visual navigation cards
<table data-view="cards">
Creates clickable card grid for section navigation
Downloadable files
<div data-gb-custom-block data-tag="file"></div>
Provides files with captions and descriptions
Call-to-action links
<a class="button">
Highlights primary or secondary actions
Reusable content across pages
<div data-gb-custom-block data-tag="include"></div>
Maintains consistency for repeated content blocks
Dynamic content
<code class="expression">
Displays variable values that update automatically
Variable scope decision:
Used across multiple pages
Space-level in /.gitbook/vars.yaml
space.vars.variableName
Specific to one page
Page-level in frontmatter vars:
page.vars.variableName
Working with Existing Content
When working with an existing GitBook space that's synced to Git, follow this workflow to understand the structure:
Read SUMMARY.md first - This file contains the complete table of contents and navigation structure. It shows you:
All pages and their hierarchy
Page groups and organization
The relative paths to each markdown file
If SUMMARY.md doesn't exist - GitBook has inferred the structure from your directory layout. Browse the directory structure to understand how pages are organized.
Check .gitbook.yaml - Review this file to understand:
Where the root documentation directory is located
Any custom paths for README.md or SUMMARY.md
Existing redirects
Explore .gitbook/assets/ - Contains all uploaded images and files referenced in the documentation
Check .gitbook/vars.yaml - Contains space-level variables if any are defined
This approach ensures you understand the existing structure before making changes, helping you maintain consistency and avoid breaking internal links.
Configuration Files
.gitbook.yaml
The .gitbook.yaml file configures your GitBook space. It should be placed at the root of your documentation directory (or in a subdirectory if using monorepos).
Basic structure:
Configuration options:
root: The root directory for your documentation (default:./)structure.readme: Path to your homepage (default:./README.md)structure.summary: Path to your table of contents (default:./SUMMARY.md)redirects: Key-value pairs mapping old URLs to new page paths
Monorepo support:
For repositories with multiple documentation projects:
When setting up Git Sync, configure the "Project directory" to point to the subdirectory containing the .gitbook.yaml file.
Important notes:
Paths in
.gitbook.yamlare relative to therootoptionRedirects defined here are space-specific (apply only to this space)
For site-wide redirects across multiple spaces, use the GitBook UI instead
When using Git Sync, manage the README file only through your repository to avoid conflicts
The .gitbook Directory
When using Git Sync, GitBook creates a .gitbook directory in your repository to store assets, variables, and generated content.
Directory structure:
Important notes about .gitbook:
Assets: Images and files uploaded through the GitBook UI are stored in
.gitbook/assets/Reusable content: Each reusable content block is exported as a separate markdown file in
.gitbook/includes/Variables: Space-level variables are stored in
.gitbook/vars.yamlas key-value pairsReferences: Pages reference reusable content using
{% include "/reusable-content/rc12345" %}Images: Markdown pages reference images like
Table of contents: The
.gitbook/includesfolder and its files may appear in your space's table of contents. You may need to manually hide them from the TOC if this happens.Location: In monorepos, the
.gitbookdirectory is created in the root of each synced space (not necessarily the repository root)
SUMMARY.md
The SUMMARY.md file defines your table of contents and navigation structure. It's a markdown file with a specific format that mirrors the sidebar navigation in GitBook.
Basic structure:
Key rules:
Use
#for the main title (commonly "Table of contents" or "Summary")Use
##headings to create page groups (section headers in the sidebar)Use
*for unordered lists to define pages and subpagesIndent with spaces (not tabs) to create nested/child pages
Each list item should be a markdown link:
[Link text](path/to/file.md)Paths are relative to the location specified in
.gitbook.yaml(typically the root)
Page link titles (optional):
You can define a different title for the sidebar navigation versus the page itself:
The text in quotes ("Page link title") will be used in:
The table of contents sidebar
Pagination buttons at the bottom of pages
Any relative links to that page
Important notes:
SUMMARY.md is optional. If not provided, GitBook infers structure from your folder hierarchy
You cannot reference the same markdown file twice in SUMMARY.md (each page has only one URL)
GitBook updates SUMMARY.md automatically when you edit through the GitBook UI
The file structure reflects exactly what users see in the navigation sidebar
Markdown Formatting
GitBook uses GitHub Flavored Markdown with custom extensions.
Standard markdown:
Code blocks:
Code blocks with titles:
Inline links:
External links:
[text](https://example.com)Internal pages: Use relative file paths like
[text](page.md),[text](../folder/page.md), or[text](subfolder/page.md)Email:
[text](mailto:[email protected])
Math/TeX:
Page Frontmatter
GitBook supports YAML frontmatter at the top of markdown files to configure page-specific settings. Frontmatter must be placed at the very beginning of the file, before any content.
Available frontmatter fields:
Field descriptions:
description:- Page description text. Supports multiline with>-syntax:icon:- Icon name from Font Awesome (e.g.,book-open,bolt,stars,icons,brackets-curly)hidden: true- Hides the page from the table of contents in published documentationvars:- Page-level variables (key-value pairs) that can be referenced in expressions:if:- Adaptive content visibility condition. Controls when the page is visible based on visitor attributes:Note: While adaptive content conditions can be set in frontmatter, it's recommended to configure them through the GitBook UI for better maintainability and team visibility.
layout:- Controls page layout and which elements are visible. This maps to the "Page Options" settings in the GitBook UI:width:- Page content widthdefault- Standard content widthwide- Wider content area (automatically widens full-width blocks like tables and code)
title.visible:- Show/hide the page title (boolean:trueorfalse)description.visible:- Show/hide the page description (boolean:trueorfalse)tableOfContents.visible:- Show/hide the left sidebar table of contents (boolean:trueorfalse)outline.visible:- Show/hide the right sidebar page outline/headings (boolean:trueorfalse)pagination.visible:- Show/hide next/previous page navigation links (boolean:trueorfalse)metadata.visible:- Show/hide page metadata section (boolean:trueorfalse)
Example for a landing page with minimal chrome:
Example complete frontmatter:
Variables and Expressions
GitBook supports variables that can be dynamically displayed in your content using expressions. Variables can be defined at the space level or page level.
Variable Storage
Space-level variables are stored in /.gitbook/vars.yaml at the root of your documentation:
Page-level variables are stored in the page's frontmatter under vars::
Using Variables with Expressions
Expressions allow you to reference and display variable values dynamically in your content. Expressions use JavaScript syntax and are wrapped in <code class="expression"> tags.
Syntax:
Examples:
Variable references:
space.vars.variableName- Access space-level variables defined in/.gitbook/vars.yamlpage.vars.variableName- Access page-level variables defined in the page's frontmatter
Important notes:
Variable definitions (the actual variable storage) are managed through:
/.gitbook/vars.yamlfor space-level variablesPage frontmatter
vars:for page-level variables
Expressions can contain any valid JavaScript code and are evaluated when the page is rendered
When editing locally, you can create space variables by editing
/.gitbook/vars.yamland page variables by adding them to frontmatterThe GitBook UI provides a visual editor for managing variables, but they are fully editable in markdown files
GitBook Custom Blocks
GitBook extends standard markdown with custom block syntax using tags like {% tabs %}, {% hint %}, etc. These blocks enable rich, interactive documentation features.
Tabs
Use tabs to present alternative content like different programming languages or platform-specific instructions.
When to use: Comparing alternatives (code in different languages, platform-specific commands, configuration options).
Syntax:
Stepper
Use steppers for sequential, multi-step processes where order matters.
When to use: Tutorials, installation guides, how-to guides, onboarding checklists, any sequential process.
Syntax:
Hints
Use hints to highlight important information without disrupting flow. Supported styles: info, warning, danger, success.
When to use: Supplementary information, call-outs, best practices, warnings, troubleshooting tips.
Syntax:
Expandable
Use expandable sections for optional content that doesn't need to be visible by default.
When to use: Optional deep-dives, advanced explanations, lengthy logs, FAQ answers, content that would clutter the page.
Syntax:
Columns
Use columns to present content side-by-side (2 columns maximum).
When to use: Side-by-side comparisons (pros vs cons), before/after examples, parallel instructions.
Syntax:
Updates
Use updates blocks for product updates, release notes, or changelogs.
When to use: Changelog pages, release notes, version updates, product announcements.
Syntax:
Cards
Use cards to create visual, clickable navigation elements. Cards are HTML tables with special attributes.
When to use: Dashboards, feature overviews, linking to related pages, showcasing multiple resources.
Syntax:
Embeds
Use embeds to include external content like videos, interactive demos, or social media.
When to use: Demonstration videos, interactive code sandboxes, tweets, external rich media.
Syntax:
Files
Use file blocks to provide downloadable files with captions.
Syntax:
Buttons
Use buttons for clear call-to-action links. Supported styles: primary and secondary.
When to use: Download links, "Try it now" actions, external resource navigation.
Syntax:
Buttons with icons:
Icons use Font Awesome names (without the fa- prefix).
Icons
Inline icons from Font Awesome can enhance text readability.
When to use: Visual indicators, status icons, improving scannability.
Syntax:
Reusable Content
Reusable content blocks let you sync content across multiple pages.
When to use: Call-to-actions, disclaimers, repeated instructions, any content that needs to stay consistent across pages.
Syntax:
Note: Reusable content blocks are different from pages. They're created through the GitBook UI and given unique IDs.
OpenAPI Specifications
OpenAPI specifications enable interactive, testable API documentation in GitBook. However, OpenAPI specs cannot be added directly to markdown files.
How to add OpenAPI specs:
OpenAPI specifications must be uploaded through one of these methods:
GitBook API - Use the OpenAPI endpoints to programmatically upload specs
GitBook CLI - Use the
gitbook openapicommandGitBook UI - Upload specs through the web interface
Once uploaded, you can reference API methods in your markdown using the OpenAPI block syntax:
Important notes:
You cannot embed OpenAPI spec content directly in markdown files
The
srcURL must point to an already-uploaded OpenAPI specificationFor more information, see the GitBook OpenAPI documentation
Nested Markdown in Custom Blocks
Markdown formatting works inside custom block tags. Maintain standard markdown syntax within custom blocks:
Common Pitfalls
File organization:
Don't reference the same markdown file twice in SUMMARY.md
Keep file paths consistent between SUMMARY.md and actual file locations
Use relative paths consistently
Configuration conflicts:
When using Git Sync, manage README.md only through your repository
Keep .gitbook.yaml at the correct root level for your project
Test redirects after moving or renaming files
Markdown formatting:
Tables and columns are discouraged (use custom blocks instead)
Avoid excessive nested lists (keep hierarchy simple)
Don't mix tab/space indentation in SUMMARY.md
Custom blocks:
Always close blocks properly (
{% endtab %},{% endhint %}, etc.)Match opening and closing tags exactly
Test custom blocks in GitBook after editing locally
Working with Git Sync
When GitBook is synced with Git:
Changes in Git automatically update GitBook
Changes in GitBook automatically commit to Git
GitBook maintains SUMMARY.md based on UI edits
Merge conflicts should be resolved in Git
Best practices:
Make structural changes (navigation) through SUMMARY.md in Git
Make content changes either in Git or GitBook UI (be consistent)
Review auto-generated commits from GitBook
Use branch-based workflows for significant updates
Test changes in a preview before merging to main
Example Complete Page
Here's a complete example showing multiple GitBook features:
Last updated
Was this helpful?

