Optimize Your Site's HTML Code with WPMasterToolKit's "Disable WordPress Shortlink Tag" Module
By default, WordPress inserts a <link>
for shortlinks in the <head>
and adds a corresponding HTTP header. These shortlinks, although sometimes useful, are rarely used by visitors or administrators in modern scenarios. With the Disable WordPress Shortlink Tag from WPMasterToolKit, you can easily remove this unnecessary tag and header, optimizing your site.
Why disable shortlinks?
WordPress shortlinks were designed to provide a short version of your URLs, particularly useful for sharing links. However:
- Limited use : In many cases, shortlinks are unused and their removal does not affect your site's core functionality.
- Performance: Reducing unnecessary tags and headers lightens HTML code and slightly improves performance.
- Simplicity: Cleaner, minimal HTML code is always preferable for maintenance and SEO purposes.
Main features of the Disable WordPress Shortlink Tag module
- Delete tag
<link>
shortlink : Automatically deletes the shortlink tag added in the<head>
. - Deleting the HTTP shortlink header : Also disables HTTP header
X-WP-Shortlink
sent with the answers. - Automation : Once activated, the module works without any additional configuration.
- Clean HTML code : Guarantees cleaner code and a better user experience.
How does the module work?
WordPress uses two main actions to generate shortlinks:
- Action
wp_shortlink_wp_head
: Adds the<link>
shortlink in the<head>
. - Action
wp_shortlink_header
: Adds HTTP headerX-WP-Shortlink
.
The module Disable WordPress Shortlink Tag disables these two actions using the following hooks:
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
: Deletes the<link>
from<head>
.remove_action( 'template_redirect', 'wp_shortlink_header', 100, 0 );
Disables HTTP header.
How do I use the Disable WordPress Shortlink Tag module?
- Activate the : Go to the WPMasterToolKit dashboard and activate the module Disable WordPress Shortlink Tag.
- Automation : The module automatically removes the shortlink tag and header from your site.
- Check the results: Inspect your site's source code for the absence of the
<link>
and headerX-WP-Shortlink
.
Use cases
- Modern sites : Most sites don't use WordPress' built-in shortlinks, preferring tools like Bitly or TinyURL to create short links.
- SEO and optimization : Cleaner HTML code can help search engines better understand your site.
- Performance: Removing unnecessary content from the DOM and HTTP headers slightly reduces response size and improves loading times.
Technical documentation: the hooks used
The module uses two main hooks to disable shortlinks:
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
Deletes the<link>
automatically generated by WordPress for shortlinks.
Example:remove_action( 'wp_head', 'wp_shortlink_wp_head' );
remove_action( 'template_redirect', 'wp_shortlink_header', 100, 0 );
Disable HTTP headerX-WP-Shortlink
sent by WordPress.
Example:remove_action( 'template_redirect', 'wp_shortlink_header', 100, 0 );
Our technical choices
- Universal compatibility : This module is compatible with all modern versions of WordPress where shortlink actions are used.
- Easy to use : Once activated, the module operates automatically without manual configuration.
- Target impact : By deleting only unnecessary elements, the module doesn't affect any other site functionality.
Conclusion
The module Disable WordPress Shortlink Tag from WPMasterToolKit is ideal for administrators who want to optimize their WordPress site by removing unnecessary tags and headers. If you don't use WordPress's built-in shortlinks, this module is a simple and effective solution to lighten your HTML code and slightly improve performance.