Last active
April 10, 2025 14:16
-
-
Save paulcollett/4c81c4f6eb85334ba076 to your computer and use it in GitHub Desktop.
Remove Yoast HTML Comments “This site is optimized with the Yoast WordPress SEO plugin”
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For Yoast SEO Plugin Version: 14.1+ add to your Wordpress Theme's functions.php... | |
// Remove All Yoast HTML Comments | |
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 | |
// Credit @devendrabhandari (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-3303423) | |
add_filter( 'wpseo_debug_markers', '__return_false' ); | |
// For Yoast SEO Plugin Version: < 14.1 add to your Wordpress Theme's functions.php... | |
// Remove All Yoast HTML Comments | |
// https://gist.github.com/paulcollett/4c81c4f6eb85334ba076 | |
// Credit @maxyudin (https://gist.github.com/paulcollett/4c81c4f6eb85334ba076#gistcomment-2937964) | |
add_action('wp_head',function() { ob_start(function($o) { | |
return preg_replace('/\n?<.*?yoast seo plugin.*?>/mi','',$o); | |
}); },~PHP_INT_MAX); |
Still works in April 2025. 🙂
In the latest versions of Yoast, the setting already includes the functionality to remove comments and other elements from the header.
Where is the setting exactly?
Remove powered by HTTP header
option under Crawl optimization doesn't remove this.I'm on Yoast 24.8.1
Sorry, I was wrong 😞 — there’s no option to remove comments, but I could swear it was there at some point 🤔. Now I’m left with doubts. I use Autoptimize and WP Super Cache; they remove all comments, including the “Powered by Yoast” one. Cheers.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where is the setting exactly?
Remove powered by HTTP header
option under Crawl optimization doesn't remove this.I'm on Yoast 24.8.1