Skip to content

How to Fix Confluence Anchor Links

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Confluence Anchor Links. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Links to specific sections on a Confluence page scroll to the top instead of the intended heading. Confluence generates heading anchors automatically but may conflict.

The Wrong Way

// Using an HTML <a> tag as an anchor
page.content += '<a name="my-section"></a>';

Confluence's storage format strips raw HTML anchors. They disappear after page save.

The Right Way

Step 1: Use heading anchors (automatic)

# Every heading in Confluence gets an auto-generated anchor
# Format: <heading-text> (lowercase, spaces → hyphens)
# Example: "## My Section" → #my-section
# Full URL: https://your-space.atlassian.net/wiki/.../page#my-section
# Hover over the heading → a link icon (🔗) appears
# Click it → copies the anchor link to your clipboard
# Paste this link wherever you need to reference the section

Step 3: Handle duplicate headings

# If two headings are "Requirements":
# Confluence adds a suffix:
# #requirements → first occurrence
# #requirements-1 → second occurrence
# #requirements-2 → third occurrence

To find the correct anchor, hover and click the link icon on the second heading.

Step 4: Use the anchor macro for non-heading targets

# Insert → Other Macros → "Anchor"
# Give it a name: "decision-point-1"
# Link to: #decision-point-1

The Anchor macro works on any element, not just headings.

Anchor link "##API Reference" now navigates correctly — scrolls to the API Reference section from anywhere in the page.

Prevention

  • Use Anchor macros only when headings are not available or appropriate.
  • Check anchor links after renaming headings — anchors change when heading text changes.
  • The anchor-generation logic is similar to Doda Browser's reader mode, which creates a table of contents from heading anchors automatically.
  1. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  2. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  3. Misunderstanding that String is [Char] with poor performance for large text operations

These mistakes appear frequently in real-world CONFLUENCE code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why did my Confluence anchor link stop working?

You renamed the heading. Confluence anchors are based on heading text. Renaming "API Setup" to "Setup Guide" changes the anchor from #api-setup to #setup-guide. Update all links to the new anchor.

Yes. The URL format is: [page-url]#anchor-name. For example: https://your-space.atlassian.net/wiki/spaces/DEV/pages/12345/Page#my-section. Copy the link from the heading icon on the target page.

Do Confluence anchors work in PDF exports?

Yes. Anchor links in the PDF are converted to internal PDF links that navigate to the corresponding page and section. This works for both auto-generated heading anchors and Anchor macros.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro