How to keep Confluence in sync with Markdown docs in Git
Updated 2 December 2026 · 7 min read
Short answer: Make the Git repository the source of truth and publish one way, from Git to Confluence, on every merge or at release time. Use a publisher that remembers which file maps to which page, such as the open-source mark or md2conf in CI, or re-import manually with an app that keeps a sync map. Treat the Confluence pages as read-only output, because a publish overwrites edits made there. Two-way editing needs a lossless round trip between Markdown and Confluence's page formats, so decide up front which side wins.
Which side should be the source of truth?
Pick one source per page. Syncing the same page in both directions is where edits get lost.
| Option | How it works | Use it when | Main risk |
|---|---|---|---|
| Git is the source | CI publishes Markdown to Confluence on merge, and Confluence is read-only by convention | Docs live with the code and are reviewed in pull requests | Edits made in Confluence are overwritten |
| Confluence is the source | Writers edit in Confluence and export to Markdown when needed | Non-developers write and comment on the docs | Markdown copies in Git go stale |
| Split by section | Reference docs come from Git, while meeting notes and decisions live only in Confluence | Mixed audiences share one space | Needs a clear boundary that people respect |
For engineering docs such as runbooks, architecture notes and API guides, the first option is the usual choice.
How does one-way publishing from Git to Confluence work?
- A change merges to the main branch.
- A CI job runs a publisher over the docs folder.
- The publisher converts each Markdown file to Confluence's format and finds the matching page, or creates it.
- It writes the new body and rewrites relative links between files to Confluence URLs.
- Confluence records the change as a new page version.
The Confluence REST API update call requires the new version.number (the current version plus one) and the complete body, as the page API documents. So each publish replaces the body with what your file says. That is what keeps Git authoritative, and it is also why Confluence-side edits do not survive.
How should a publisher remember which file is which page?
Without a stable file-to-page link, every rename or title change creates a duplicate. There are three approaches:
| Approach | Examples | Where the link lives | Trade-off |
|---|---|---|---|
| Match by title | mark, by default | The page title in the file header | Changing a title points at a different page |
| Page ID in the file | md2conf | A comment or front matter in the Markdown | Explicit and stable, but adds commits and ties files to one space |
| Mapping stored elsewhere | mark with --track-pages, Folio for Confluence | Confluence for mark, Forge storage per space for Folio | Keeps Markdown clean, but the mapping belongs to that space and tool |
A page's numeric ID, the number in its URL, stays the same when the page is renamed, which is why ID-based tracking is the most stable of the three.
Which open-source publishers can run in CI?
Three open-source projects publish Markdown to Confluence Cloud. Check each README and license before adopting one, because behavior and maintenance change.
- mark (Apache-2.0) publishes with a command such as the one in its README, and also reads
MARK_USERNAME,MARK_PASSWORDandMARK_BASE_URLfrom the environment. Its--dry-runoption shows the resolved pages and HTML without writing anything. - md2conf (MIT) links a file to a page by an ID in a comment or front matter. For pages it matches by title, it only updates pages that trace back to a trusted ancestor, which stops it from touching unrelated pages. Front matter
synchronized: falseexcludes a file. - markdown-confluence is a GitHub Action around an npm CLI, and the same project offers an Obsidian plugin. It publishes Markdown as Atlassian Document Format to Confluence Cloud as child pages of a parent page you name, and front matter
connie-publish: falseexcludes a file.
mark's documented command line (the file header and the command are examples):
<!-- Space: DOCS -->
<!-- Parent: Guides -->
<!-- Title: Release process -->
mark publish -u user -p token -b https://example.atlassian.net/wiki -f "docs/**/*.md"
An example GitHub Actions workflow for markdown-confluence, based on the action's own listing (check it for the current version):
name: Publish docs to Confluence
on:
push:
branches: [main]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: markdown-confluence/publish-action@v7
with:
confluenceBaseUrl: https://your-domain.atlassian.net
confluenceParentId: 123456
atlassianUserName: ${{ secrets.ATLASSIAN_USERNAME }}
atlassianApiToken: ${{ secrets.ATLASSIAN_API_TOKEN }}
folderToPublish: docs
contentRoot: .
How do you give CI access to Confluence safely?
Create a dedicated service account in Atlassian Administration and issue the token for it, not for a person. Atlassian recommends tokens with scopes, and tokens expire after one year by default (you can choose 1 to 365 days). Store the token as a repository secret and put the expiry date in a calendar, because a CI job that silently starts failing is how docs go stale. Tools differ in how they authenticate with scoped tokens, so follow their README.
How do you avoid lost edits in Confluence?
Nothing technical stops a person from editing a synced page, so combine four measures:
- Restrict editing. On each synced page, open Share, set General access to Open with Can view so everyone can read but not edit, then add the publishing account under Specific access with Can edit. Edit restrictions are not inherited by child pages, so apply them to every page in the tree.
- Say where the source is. Put a line at the top of each file, such as
> Source: docs/runbooks/deploy.md in the platform repo. Edit it there; changes made in Confluence are overwritten. - Detect edits before publishing.
GET /wiki/api/v2/pages/{id}returns the current version number and theauthorIdof the person who created it. If that is not your service account, fail the job or open a pull request instead of overwriting. - Know how to recover. Open More actions, then Version history, then Restore this version. Restoring saves the old content as a new latest version and keeps the history.
If people need to comment on or co-author a document, move it out of the synced tree rather than fighting the publisher.
How do you avoid duplicate pages?
- Keep titles unique. Confluence allows one page per title in a space, so two
README.mdfiles will clash unless the tool disambiguates them or you set explicit titles. See duplicate page titles when importing Markdown. - Choose the tracking method before the first publish. Switching from title matching to IDs, or from one tool to another, can create a second copy of every page unless the new tool adopts the existing ones. Folio has an option to adopt existing untracked pages with matching titles, and md2conf matches by title inside trusted subtrees.
- Decide what happens on delete and rename. Check your publisher's documentation for what it does when a file disappears. Do not assume the page is removed.
Can you sync by re-importing manually with Folio for Confluence?
Yes, if publishing on every merge is more than you need. Folio updates pages in place from a per-space sync map that ties file paths to page IDs. Steps:
- Pull the latest main branch and open Space apps → Folio for Confluence in the target space.
- On the Import tab, drop the docs folder or a
.zipof it. - Review the page tree preview, choose the parent page and import.
- Open the Audit & fix tab and score the section. It flags leftover
.mdpaths, localhost links and stale pages, and you review any proposed fix before it is applied.
Limits: this is a manual run, not a scheduled or CI sync, and it does not push edits from Confluence back to Git. The pages take their content from your files, and every change is saved in page history. Folio is for Confluence Cloud only.
FAQ
Can Confluence pull Markdown from a Git repository by itself?
Confluence Cloud has no built-in sync that turns a repository's Markdown into pages. Publishing happens through a CI tool, a Marketplace app or your own script calling the REST API.
What happens to edits made in Confluence on a synced page?
The next publish replaces them, because the REST API update writes the full page body from your file. The earlier version stays in page history, where someone can compare it or restore it with More actions and then Version history.
Should I commit Confluence page IDs to Git?
It depends. IDs in the files, as md2conf writes them by default, make the mapping explicit and survive renames, but they add commits and tie files to one space. A mapping stored outside the repository keeps the Markdown clean but is lost if you recreate the space or switch tools. Decide before the first publish.
How often should the sync run?
Run it on every merge to the main branch for reference docs that people read in Confluence as if they were live. Nightly is enough for slow-moving docs, and a manual re-import at release time suits docs that only change with releases.