How to prevent broken internal links in WordPress
Prevent broken internal links by choosing a stable permalink structure, creating links through WordPress’s page search instead of typing relative URLs, and adding redirects whenever a URL changes. For WPML multilingual sites, an ID-based linking addon can update destinations automatically.
- 01Choose a stable permalink structure
- 02Create links from WordPress search
- 03Generate theme links dynamically
- 04Redirect every changed URL
- 05Check links after site changes
- 06Use an ID-based addon for WPML
What you need
- WordPress administrator access
- A recent site backup
- A way to crawl or check internal links
Choose a stable permalink structure
Go to Settings → Permalinks and choose a structure you expect to keep. Avoid changing the structure on an established site unless you have mapped the old URLs to their replacements. WordPress describes permalinks as permanent URLs, but changing the structure can alter many existing addresses at once.
After any deliberate permalink change, click Save Changes. This applies the rewrite rules for the selected structure. Check a few posts, pages, categories, and custom post types before declaring the change complete.
Create links from WordPress search
When editing content, select the text, choose the link control, and search for the destination by page or post title. WordPress can search your own content and insert its URL, which is safer than typing a relative link such as page-name. A relative link can resolve against the current page path and produce a 404 after a parent page changes.
For menus, buttons, widgets, and reusable blocks, open each item and confirm that it points to the intended page. Do not assume that changing a page title also updates every URL already stored in post content.
Generate theme links dynamically
If a link is produced by a theme, template, shortcode, or custom PHP, avoid hard-coding the page URL. Pass the destination post or page ID to WordPress’s get_permalink() function so the current permalink is generated when the page is displayed.
This approach is useful for repeated calls to action, breadcrumbs, related-content controls, and parent-page links. It does not automatically repair URLs already saved inside ordinary post content, menus, or third-party fields, so those still need an audit.
Redirect every changed URL
When you rename a slug, move a page, or change a permalink structure, keep the old address redirecting to the exact new address. WordPress stores old slugs for published posts and has core logic that can redirect some old post URLs, but this is not a complete migration plan: hierarchical pages and complex structure changes need deliberate checking.
Update your internal links to the final URLs as well. A redirect is a safety net for old bookmarks and external links, not a reason to leave your own site linking through old addresses. Avoid redirect chains, redirect loops, and sending several unrelated old URLs to the home page.
Check links after site changes
Run a crawl after changing slugs, parent pages, domains, HTTPS, or permalink settings. Review 404 responses, redirecting internal links, links pointing to staging URLs, mixed HTTP and HTTPS URLs, and links that resolve differently depending on the current page path.
Do not rely on a broken-link checker alone. A support case showed that a checker could miss links which still contained an old URL after a page was moved, even though visitors reached a 404. Open representative links in a private browser window and check important templates manually.
Use an ID-based addon for WPML
The manual approach is fine for a small, stable site: use WordPress’s internal search, generate template links from IDs, and maintain redirects when URLs change. For a multilingual WPML site with frequent page moves, slug edits, or parent changes, consider WPML Sticky Links Addon as the fast route.
It associates internal links with page IDs and resolves the current permalink when the page is displayed, including links between language versions. That reduces the number of saved URLs you need to repair after structural changes, but you should still crawl the site after major migrations.
Let WPML Sticky Links Addon do it
ID-based links that survive slug, parent, and permalink changes; choose it for WPML multilingual sites needing automatic link updates.
Sources
- wordpress.org /documentation/article/customize-permalinks/?utm_source=open…
- wordpress.org /documentation/article/settings-permalinks-screen/?utm_sourc…
- wordpress.org /documentation/article/link-editing/?utm_source=openai
- developer.wordpress.org /reference/functions/get_permalink/?utm_source=openai
- developer.wordpress.org /reference/functions/wp_check_for_changed_slugs/?utm_source=…
- wordpress.org /support/topic/broken-internal-links-after-moving-a-page-are…
Questions
- Does WordPress automatically update internal links when I change a slug?
- No, WordPress does not reliably rewrite every internal URL already saved across posts, menus, widgets, and plugin fields. It stores old slugs for published content and can redirect some old post URLs, but page hierarchies and larger permalink changes still require an audit, redirects, and updates to internal links.
- Should I use full URLs or relative URLs for internal links?
- Use WordPress’s link search or a generated permalink rather than typing a relative URL by hand. A relative link without the correct leading path can be resolved against the current page location, so it may work on one page and return a 404 on a child page after the hierarchy changes.
- What should I do after changing WordPress permalink settings?
- Save the new setting, test representative URLs, and check that old URLs redirect to the correct new URLs. Then crawl the site for 404s and internal links that still point to redirected addresses. Changing the structure can affect posts, pages, archives, menus, and content links, so do not treat saving the setting as the whole migration.
- Can I prevent broken links without installing a plugin?
- Yes, a small or stable site can manage this manually. Keep a stable permalink structure, create links through the editor’s internal search, use <code>get_permalink()</code> for links generated in code, and add redirects for changed URLs. A plugin becomes useful when the site is multilingual or has many frequently changing links that are difficult to maintain by hand.