Are you looking for an easy way to add anchor links to your blog posts and pages?
Anchor links are often used in the table of content sections because they help users move up and down a lengthier article without reloading the page. It can also help with SEO as Google may show your content in featured snippets.
In this guide, we will show you how to easily add anchor links in WordPress.
What is an Anchor Link?
An anchor link is a type of link on the page that brings you to a specific place on that same page. It allows users to jump to the section they’re most interested in.
As you can see, clicking on the anchor link takes the user to the specific section on the same page.
Anchor links are commonly used in lengthier articles as the table of contents which allows users to quickly jump to the sections they want to read.
Another use of anchor links is to create bookmark links on your WordPress site. This allows you to share the bookmark link on social media or email newsletters, so when the page loads your users immediately jump to the section you want them to see.
Why and When Should You Use Anchor Links?
An average user spends less than a few seconds before deciding if they want to stay or leave your WordPress website. You have just those few seconds to convince users to stay.
The best way to do that is to help them quickly see the information they’re looking for.
Anchor links make this easier by allowing users to skip the rest of the content and jump directly to the part that interests them. This improves user experience and helps you win new customers/readers.
Anchor links are also great for WordPress SEO. Google can display several anchor links in the search results as a jump-to link.
This is proven to increase the click-through rate in search results. In other words, you get more traffic to your website.
If you create a table of contents using anchor links, then Google can also display the headings in featured snippets.
Having said that, let’s take a look at how to easily add anchor links in WordPress. Below is a list of all the topics we will cover in this guide.
Go ahead and click on any of these anchor links below, and you’ll be taken to that specific section.
How to Manually Add Anchor Links in WordPress
If you just want to add a few anchor links or bookmark links in your article, then you can easily do so manually.
Basically, you need to add two things for an anchor text to work as intended:
- Create an anchor link with a # sign before the anchor text.
- Add the
idattribute to the text where you want the user to be taken.
Let’s start with the anchor link part.
Step 1. Creating an Anchor Link
First, you need to edit or create a new post or page. Next, select the text that you want to link and then click on the insert link button in the WordPress block editor.
This will bring up the ‘insert link’ popup where you usually add the URL or look for a post or page to link.
However, for an anchor link, you’ll simply use # as a prefix instead of HTTPs. Just enter the keywords for the section you want the user to jump to after that.
Then, click on the enter button to create the link. It won’t go anywhere yet, though. You will have to create the ID in the next step.
Some helpful tips on choosing what text to use as your anchor # link:
- Use the keywords related to the section you are linking to.
- Don’t make your anchor link unnecessarily long or complex.
- Use hyphens to separate words and make them more readable.
- You can use capitalization in anchor text to make it more readable. For example:
Once you’ve chosen the right link text, it’s time to anchor it to an area, section, or text on the page that you want to show when users click on the anchor link.
Step 2. Add the ID attribute to the linked section
In the content editor, scroll down to the section that you want the user to navigate to when they click on the anchor link. Usually, it is a heading for a new section.
Next, simply select the block. Then, in the block settings on the left panel, click on the ‘Advanced’ tab to expand it.
After that, you need to add the same text that you added as the anchor link under the ‘HTML Anchor’ field.
Make sure that you add the text without the # prefix.
You can now save your post and see your anchor link in action by clicking on the preview tab.
What if the section you want to show is not a heading but just a regular paragraph or any other block?
In that case, you need to click on the three-dot menu on the block settings and select the ‘Edit as HTML’ option.
This will allow you to edit the HTML code for that particular block. You need to select the HTML tag for the element you want to point to. For example,
<p> if it is a paragraph, or
<table> if it is a table block, and so on.
Now, you need to add your anchor as the ID attribute to that tag, like the following code:
Then you can just click the ‘Edit Visually’ button again, and your anchor link will direct the user to that block when clicked.
How to Manually Add Anchor Link in Classic Editor
If you are still using the older classic editor for WordPress, then here is how you can add the anchor link / jump link.
Step 1. Create the anchor link
First, you’ll need to edit or create a new post or page. After that, select the text that you want to change into the anchor link and then click on the ‘Insert Link’ button.
After that, you need to add your anchor link with a # prefix followed by the slug you want to use for the link.
Step 2. Add the ID attribute to the linked section
The next step is to point the browsers to the section you want to show when users click on your anchor link.
For that, you’ll need to switch to the ‘Text’ mode in the classic editor. After that scroll down to the section that you want to link to.
Now locate the HTML tag you want to target. For example,
<p>, and so on.
You need to add the ID attribute to it with your anchor link’s slug without the # prefix, like this:
You can now save your changes and click on the preview button to see your anchor link in action.
How to Manually Add Anchor Links in HTML
If you are used to writing in the Text mode of the old Classic Editor in WordPress, then here is how you would manually create an anchor link in HTML.
First, you need to create the anchor link with a # prefix using the usual
<a href=""> tag, like this:
<a href="#best-coffee-shops-manhattan">Best Coffee Shops in Manhattan</a>
Next, you need to scroll down to the section that you want to show when users click on the link.
Usually, this section is a heading, but it could be any other HTML element or even a simple paragraph <p> tag.
You need to add the ID attribute to the HTML tag, and then add the anchor link slug without the # prefix.
<h2 id="best-coffee-shops-manhattan">Best Coffee Shops in Manhattan</h2>
You can now save your changes and preview your website to test the anchor link.
How to Automatically Add Headings as Anchor Links in WordPress (Recommended)
The best way to automatically add anchor links in WordPress is by using the All in One SEO (AIOSEO) plugin. This method is suitable for users who regularly publish long-form articles and need to create a table of contents with anchor links.
AIOSEO is the best SEO plugin for WordPress and it comes with a built-in WordPress block for adding a table of contents.
For this tutorial, we’ll use the free AIOSEO Lite version because it includes the table of contents block. There’s also an AIOSEO Pro version that includes more features for helping you rank better on search engines.
The first thing you need to do is install and activate the AIOSEO plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, you’ll see the setup wizard. Simply click the ‘Let’s Get Started’ button and follow the onscreen instruction.
For more details, please see our guide on how to set up All in One SEO for WordPress.
Next, you can create or edit a new post or page where you’d like to add anchor links. Once you’re in the content editor, simply click the ‘+’ button and add the ‘AIOSEO – Table of Contents’ block.
The plugin will automatically detect different headings on your page and show them in the table of contents.
You can further customize each anchor link in the block. For instance, there is an option to change the ‘List Style’ from bullets to numbers in the settings panel on the right.
Plus, you can rename the headings, rearrange their order in the table of contents block, and hide specific headings.
You can now save your changes and preview your article. The plugin will automatically display a list of anchor links as your table of contents.
For more detailed instructions, see our article on how to add a table of contents in WordPress.
We hope this article helped you learn how to easily add anchor links in WordPress. You may also want to see our tips on how to properly optimize your blog posts for SEO and our pick of the best WordPress page builder plugins.