-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PWA 'pages' should set meta robots indexing directives #300
Comments
Good point. Given the current codebase, this can be done via: --- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -111,6 +111,7 @@ function wp_add_error_template_no_robots() {
function wp_unauthenticate_error_template_requests() {
if ( is_offline() || is_500() ) {
wp_set_current_user( 0 );
+ add_action( 'wp_head', 'wp_no_robots' );
}
} However, we may want to rename |
Hold on. Is this not already being done? See this code: pwa-wp/wp-includes/general-template.php Lines 90 to 101 in 77c0944
|
Is not the |
Yep, that's indeed equivalent. Good catch; I was checking HTTP headers but neglected to check the HTML source... Oops! |
Just looks like we're missing the x-robots-tag output on |
Why is it needed for the service worker script? Other scripts served by WordPress don't have that header (e.g. jQuery). |
(most) other scripts are obviously scripts (e.g., ending in |
Right, but is it necessary? Do any search engines index JS assets? |
They may do, if they don't realise that they're JS assets. This isn't the only use-case, too. Anecdotally, I'm currently dabbling with setting various HTTP headers on different templates/pages (mostly for preloading/pushing resources), and there's no 'clean' way to exclude service worker results pages. People are going to continually run into this kind of problem, whilst we have a dynamically generated/served JavaScript file which presents as a page. The situation isn't radically different from |
Sorry for the long pause.
Note that in #289 the URL for service workers will be In any case, the In any case, I've opened a PR to add this response header: #330. |
Well, undeclared file types also leave other systems blind, so it's best practice for a 'non-page' asset to declare its type in the URL. Cloudflare, for example, only caches (by default) assets based on their file extension; regardless of the |
It's not feasible to for a WP-generated file to end in |
Yeah, I caught that. I really like |
Requests which return service worker 'pages' or content - like
example.com/?wp_service_worker=1
,example.com/?wp_error_template=offline
andexample.com/?wp_error_template=500
(and any other/similar responses) - should indicate that they shouldn't be indexed by search engines or social media.This can be achieved by returning an
x-robots-tag
HTTP header with such responses, with a value ofnoindex, follow
.The text was updated successfully, but these errors were encountered: