Skip to main content

Anchor Link

The Anchor Link component inserts a tiny piece of code that allows you to link to a specific location on a web page.

Uses

An anchor link is a tiny piece of code that is appended to a hyperlink. The anchor allows you to link to a specific location on a page.

If a web page URL is like an apartment building address, then the anchor is like your apartment number – a specific location within that address.

Anchor links are often used with the Anchor Navigation component, which allows visitors to easily navigate a long web page. For example, this page has anchor navigation pointing to anchor links for Uses, Best practices and Accessibility. Click on an item in the anchor navigation and it will take you directly to that section of the page.

Best practices

When to use an anchor link

  • Anchor links work best on long pages that would otherwise be difficult to navigate. 
  • Don't use anchor links on short pages that are simple to navigate.
  • In general, avoid using an anchor link to another page because the change in context may confuse the visitor.

Set up an anchor

  1. In the AEM Sidekick, expand the Concordia section.
  2. Drag the Anchor Link component to the appropriate place on your page.
  3. Give it a simple URL-friendly name (lower-case, no spaces). For example:
    • support
    • advisors
    • bestpractices
    • best-practices

    This is called the anchor ID.
Screenshot showing Anchor Link commponent open for editing. Anchor link field says support
  1. Now you'll need to link to the anchor ID. The method varies a bit depending on the situation.

(a) To link from text in a WYSIWYG to an anchor on the same page:

  • Open the WYSIWYG component.
  • Highlight the relevant text.
  • Click the hyperlink icon.
  • Enter # followed by the anchor ID:
Screenshot of hyperlink pop-up. Link to field says #support

(b) To link to an anchor on another page, enter the URL followed by # and the anchor ID:

Hyperlink open for editing. Link to field shows end of link which reads es/marketing-communications.html#advisors

(c) If you're linking from an Anchor Navigation component, add only the anchor ID.

Anchor navigation component open for editing. There are 3 anchor links: uses, bestpractices and accessibility
  1. Click OK.
  2. Test the anchor link by clicking on it. You may have to activate the page to do this.
  3. If your anchor link doesn't work, it's usually because the anchor ID doesn't fully match the anchor link. Carefully examine the anchor ID and the anchor link, and resolve any differences.

Accessibility

Hyperlinks make a promise to your visitor. Ensure the context of your content is clear so that someone landing at that anchor (perhaps mid-page) clearly understands where they are.

Back to top

© Concordia University