Docs-as-code for Confluence: publish a GitHub folder as searchable pages
Docs-as-code means keeping documentation as plain text files, such as Markdown, in the same Git repository as the code. The docs are written, reviewed and changed with the same tools as the code.
Many teams also want those docs in Confluence, where readers search and browse. Copies made by hand go out of date. This guide shows how to publish one folder of a public GitHub repository as ordinary Confluence pages.
The usual problems
A common way to show Markdown in Confluence is a macro that draws the file inside a page. The text appears, but it is not stored as page content, so:
- Confluence search may not find it.
- Links between Markdown files often break.
- A folder of docs does not become a page tree.
Git Docs Sync for Confluence works differently. It writes real Confluence pages from the Markdown, so Confluence search, page history and page permissions apply to them. The app is a free beta on the Atlassian Marketplace, provided by AVIRA LLC.
Set up the sync
You need a Confluence Cloud site where you are a Confluence admin, and a public GitHub repository. No CI pipeline, API token or command-line tool is needed.
- Install Git Docs Sync for Confluence from the Atlassian Marketplace.
- In Atlassian Administration, go to Connected apps, open the ⋯ menu next to Git Docs Sync for Confluence, and select Configure.
- Fill in the settings and select Save.
- Select Sync now. When the sync finishes, the page shows its report.
| Setting | What to enter |
|---|---|
| GitHub repository (public) | owner/name, or the repository's github.com address |
| Branch (empty = default branch) | Leave empty to use the default branch |
| Folder (empty = repository root) | The folder that holds your docs, such as docs |
| Confluence space key | The key of the space that receives the pages, such as DOCS |
| Parent page id (empty = space home page) | Optional. The number that identifies the page to publish under |
| Render Mermaid and PlantUML diagrams | On by default |
| Schedule | Off, Hourly or Daily |
A few things to know:
- Sync now uses the saved settings. Select Save before you select Sync now.
- Changing the repository, folder, space or parent page asks you to confirm with Confirm and save. Pages from the old source stay in place and are no longer updated.
- Only a Confluence admin with edit access to the parent page can save settings or start a sync. With no parent page set, the space home page is the one checked.
- Schedule runs the sync for you. Hourly runs once an hour. Daily runs about once a day.
- The report lists when the last sync ran, its result, and the counts of pages created, updated, unchanged, failed and removed in the repo. Each file with a problem is listed with the reason.
To update the pages after you change the repository, select Sync now again, or let the schedule run it. Only pages whose content changed are updated, and no file gets a second page.
What gets converted
- Each
.mdor.markdownfile becomes one page. Each subfolder that holds Markdown becomes a parent page, so the folder tree becomes the page tree. - A folder's
README.mdbecomes that folder's page. If there is none,index.mdis used. A folder with neither lists its child pages. - A page's title is the file's first level-1 heading. Without one, the file name is made
readable:
setup-guide.mdbecomes "Setup guide". If the title is already used in the space, the folder path is added in parentheses. - Links to other synced files open their pages, including links to a heading. Links to other files in the repository open on github.com. Web and email links stay as they are.
- Images show in place. Images stored in the repository load from GitHub. Images given by a full
https://address load from that address. - Code blocks become Confluence code blocks. Tables and task lists carry over. HTML that the app does not support is shown as text and never run.
- Mermaid and PlantUML blocks show as images when diagram rendering is on. When rendering is off, or a diagram fails, the block stays as code with a short note.
- Every synced page starts with a note that links to its source file on GitHub. Edit the Markdown on GitHub, not the page.
Limits
- Public repositories only. Private repositories and GitHub sign-in are not supported.
- One repository folder per Confluence site.
- Up to 500 Markdown files per sync, taken in alphabetical path order. Files over 1 MB are skipped and listed in the report.
- Repositories up to 100 MB, measured as GitHub's download of the whole repository. A larger one fails with a clear message.
- One-way only. Nothing is written back to Git. A page is rewritten the next time its source file changes, so edits made on the page are replaced then.
- Removed files are reported, not deleted. Their pages stay in Confluence.
- Diagram source leaves Atlassian when rendering is on. Mermaid source goes to mermaid.ink, and PlantUML source to kroki.io, inside each image address. Turn rendering off to keep diagram source inside Atlassian.
- Confluence Cloud only. Data Center and Server are not supported.
- Free beta. There is no charge while the app is in beta.
When a CLI is the better fit
If your team already runs CI and can store a Confluence API token, the free, open-source mark
command-line tool from kovetskiy/mark may suit you better. It
also creates real Confluence pages, and because it runs where your files are, it works for private
repositories too. Git Docs Sync for Confluence needs no token, command line or pipeline, but it
reads only public repositories.
Get help
For support or to report a security problem, email avirallcdev@gmail.com. The setup guide, privacy notice and end user terms are on this site.