Include file
You can include files from a GitHub repository in order to have an up-to-date version of it in a Confluence page. The macro will feature syntax highlighting for the included file and the possibility to export it in PDF or Word.
To include a file you can:
simply paste the URL
add the file macro and specify the file path
For files that are within private repositories, users will need to authenticate to view the files' content.
Include file by pasting the file’s URL
You can simply copy the URL of the GitHub file and paste it into the Confluence page.
In the following example we use the file URL of a .md
file located in a local GitHub repository. We simply paste the URL in the Confluence page as shown in the video and the macro will automatically be applied to embed the file.
To edit the macro’s options listed in the next section, you can click on the edit button present on the macro when editing the page.
Include file by adding the file macro
You can also add the macro to set further options.
In order to do so, you can in editor mode:
click on Insert > Other Macros
pick the Include GitHub File macro in the by "External Content" category
Alternatively you can type directly { GitHub File
and ENTER
to add and edit the macro.
You will then be able to specify the following:
| URL of the file |
---|---|
| Title to be displayed on top of the macro |
| Language of the file for syntax highlighting purposes |
| Display number of lines in the file (default setting is disabled) |
| Hide the file name (default setting is disabled) |
| Collapses the file content and gives the option to expand and collapse |