本文目录导读:

- What Exactly Is an Anchor Link?
- Why Would You Want to Remove Them?
- Method 1: Removing Anchor Links Manually in HTML
- Method 2: Using JavaScript to Strip Anchors
- Method 3: Removing Anchors in WordPress
- Method 4: Bulk Removal with a Database Query
- A Few Things to Watch Out For
- Final Thoughts
How to Remove Website Anchor Links: A Complete Guide
When you're managing a website, one of the small but surprisingly frustrating tasks you'll eventually run into is dealing with anchor links. Maybe you added them for a navigation menu, maybe a plugin inserted them automatically, or maybe you inherited a site from someone else and now you're stuck trying to figure out how to remove website anchor links without breaking anything. Whatever the reason, it's a common problem, and the good news is that it's usually easy to fix once you know where to look.
In this article, I'll walk you through what anchor links actually are, why you might want to remove them, and the different methods you can use depending on your situation.
What Exactly Is an Anchor Link?
An anchor link (sometimes called a jump link or fragment link) is a hyperlink that points to a specific section within the same page or another page. You'll recognize them by the hash symbol in the URL, like this:
https://example.com/page/#section-two
The #section-two part is the anchor. When someone clicks it, the browser scrolls directly to the element with that ID. They're genuinely useful for long articles, FAQ pages, and table-of-contents navigation. But they can also become a nuisance when they're outdated, duplicated, or pointing to content that no longer exists.
Why Would You Want to Remove Them?
There are several legitimate reasons:
- Broken anchors: The target section was deleted, so the link just sits there doing nothing.
- SEO concerns: Too many irrelevant anchor links can dilute your internal linking structure.
- Design changes: You redesigned the page and the anchors no longer match the layout.
- Plugin clutter: Some themes and plugins auto-generate anchor links you never asked for.
Whatever your reason, removing them is a straightforward process once you identify where they live.
Method 1: Removing Anchor Links Manually in HTML
If you only have a few anchors to remove, editing the HTML directly is the fastest route.
- Open your page in a code editor or your CMS's HTML view.
- Search for the
hrefattribute containing a symbol. - Either delete the entire
<a>tag or replace it with plain text.
For example, change this:
<a href="#pricing">See Pricing</a>
To this:
See Pricing
If you want to keep the link but remove only the anchor portion, just strip the #section part and leave the base URL.
Method 2: Using JavaScript to Strip Anchors
If you can't edit the HTML directly — say, because a plugin generates the links — you can use a small JavaScript snippet to remove anchor behavior on page load.
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.removeAttribute('href');
});
This targets every link that starts with a hash and removes the href, effectively turning it into plain text. Just be careful: this will also remove legitimate in-page navigation, so test it thoroughly.
Method 3: Removing Anchors in WordPress
WordPress users often run into this issue with table-of-contents plugins or block editor anchor settings.
- Block editor: Click the block, open the settings panel, and clear the "HTML anchor" field.
- Classic editor: Switch to the Text tab, find the anchor, and remove it manually.
- Plugins: Deactivate or configure the plugin that's inserting the anchors.
If you're using a TOC plugin, most of them have an option to disable anchor links entirely in their settings.
Method 4: Bulk Removal with a Database Query
For large sites with hundreds of pages, manual editing isn't realistic. You can run a search-and-replace query on your database, but always back up first. A safer alternative is using a plugin like Better Search Replace, which lets you target specific anchor patterns without touching raw SQL.
A Few Things to Watch Out For
- Don't break internal navigation. Some anchors are essential for menus and accessibility.
- Update your sitemap. If anchors were indexed, resubmit your sitemap after removal.
- Test on staging. Always preview changes before pushing them live.
Final Thoughts
Learning how to remove website anchor links isn't complicated, but it does require a bit of care. Whether you're cleaning up a single page or auditing an entire site, the key is to identify where the anchors are coming from and choose the method that fits your workflow. Take your time, back up your data, and your site will be cleaner and easier to manage because of it.


