This post was originally published on November 26, 2012. The post has been rewritten to show you the new and much easier way to create anchor links in WordPress.
In the past, creating page jump links required diving into HTML code. In this updated post, you’ll learn a simple way to do it with a Heading Block.
What are Page Jump Links?
Page jumping also referred to as anchor links or HTML bookmarks, is where a site visitor clicks a link and is jumped to a specific place further down or up a long page. Normal links always point to the top of a page. Anchor links are particularly useful for creating an index at the top of long pages. Like this…
In this post, you’ll learn:
- How to create an anchor link in a heading block
- Tips for Naming Anchor Links
- How to link to the anchor
- How to link to an anchor point on a different page
To Create your HTML Anchor:
- Click + to add a heading block in your page or post
- Enter your heading text
- On the right side under Block Settings, click on Advanced
- Under HTML anchor enter a unique name. (number-1, for example)
Tips for Naming Anchors
- Each HTML anchor must be unique within a page or post
- No spaces between words in an HTML anchor
- Remember HTML Anchors are case-sensitive
- An HTML Anchor can include: hyphens (-), underscores (_), colons (:), periods (.)
Now, Link to the anchor
Once you have created your anchors, you can link to them. Here’s how:
- Create a link, to go to the section in your page. The link can be made from a menu item, a button, an image or text.
- Highlight your text, image or button
- Select the link option from the block’s toolbar
- Type in the HTML Anchor you created, starting with the hashtag (#) symbol. So, if you created an Anchor named “number-1” (like we did) you would type #number-1
- Click enter
To link to a page section from your menu, open the menu in customize:
- Click Add Item
- Custom Link
- Put in the Link https://yourwebsite/#anchorname/
- Put in the Menu Label
- Click Add to Menu
Link to an anchor point on a different page
You can also link to an anchor on a different page by changing the link url and adding an anchor on that page. The url of the link would look like this https://domain.ca/otherpage#anchor.
So much simpler!
Now with the block editor in WordPress, it’s easy to create anchors in your pages and posts. It is so much simpler now without the need to edit code.