Skip to main content
Skip table of contents

Linking Source File Segments

You can display specific sections of a file from GitHub directly within Confluence by linking to line ranges in the file.

How it works

When adding a GitHub file URL to the GitHub Links macro, you can include a line range at the end of the URL. The macro will then display only that selected portion of the file.

Option 1: Manually specify line ranges

  1. Copy the URL of your file from GitHub

  2. Add the line range to the end of the URL using the following format:

    CODE
    #L5-L12
  3. Paste the full URL into the GitHub Links macro in Confluence

Example:

CODE
https://github.com/your-repo/path/to/file.json#L5-L12

The macro will display only lines 5 to 12 and include a label showing the selected range (L5–L12).

image-20260403-002042.png

Option 2: Copy a highlighted section from GitHub

  1. Open the file in GitHub

  2. Click on the starting line number

  3. Hold Shift and click the ending line number

  4. Copy the URL from your browser

GitHub will automatically include the correct line range in the URL. You can then paste this directly into the macro.

Result

  • Only the selected lines are displayed in Confluence

  • A label shows the line range (for example, L5–L12)

  • This helps focus on relevant code without displaying the entire file

Tips

  • Ensure the repository is accessible to the macro

  • Use line ranges to highlight only the most relevant code

  • Keep segments concise for better readability

Updated:

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.