Closed (won't fix)
Project:
Drupal core
Version:
9.1.x-dev
Component:
user system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Sep 2013 at 17:38 UTC
Updated:
1 Jun 2020 at 11:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
pwolanin commentedYes, I just was trying to fix this in D7 and there are similar links in comment module that cannot be altered except by hacking core.
Comment #2
pwolanin commentedComment #3
pwolanin commentedHere's a quick 1st pass at a patch.
Instead or in addition we could add to the HEAD on all these pages:
Note that the way the code is built in comment module is stupidly annoying since this attribute change would come through as a change to a translatable string, making this much less likely to be backportable.
Comment #4
eule commentedpatch works for me..great & thanks!
"no index" would be nice on pages like
https://example.org/filter/tipsi think on every drupal sites this causes a bit duplicate contentComment #5
scor commentedIf we're going to patch core, why not add these paths to robots.txt directly?
Comment #6
eule commented@scor
disallow in a robots.txt doesn´t mean that any search-engine the path will not be index. it means he has not to crawl it.
Noindex: /filter/tipsin a robots.txt means google understand it ..but it it inofficial and maybe bing,yandex or baido don´t understand this...i´m not sure.noindex on a metatag hits every bot who is knowing the standards. and it means he can crawl it ..but not index.
Comment #7
scor commentedYou're right @eule, looks like robots.txt doesn't prevent pages from appearing in the search engines index, I wasn't aware of this subtlety. From Google webmaster documentation:
So it looks like what we need is an explicit:
in the HTML, as I don't think that adding a nofollow will be sufficient either. This is particularly true if there are other links pointing to these pages, including external sites.
Comment #8
scor commentedupdating title. Note that this is what wordpress does for example: http://wordpress.com/wp-login.php
Comment #9
eule commentedif someone give some tips / hints i will dig into it
Comment #10
scor commentedEither (1) the user module could implement HOOK_preprocess_html() and execute drupal_add_html_head() if the path is '/user/login' or '/user/register'. OR (2) you could add a drupal_add_html_head() inside the respective form builders '\Drupal\user\Form\UserLoginForm' and 'user.register'. I'm not sure which one is kosher in D8.
Comment #11
eule commentedget it not working ;(
need the pros!
Comment #12
eule commentedHello,
i try this in
.core/modules/user/lib/Drupal/user/Plugin/Block/UserLoginBlock.phpbut it is still not working :-) maybe i put it in the wrong file or position?
any one with help please?
Comment #13
scor commentedSome sites might want to have their user/register form indexed I think.
Comment #14
eule commentedthen makes an option for the admins who don´t want it
Comment #15
xjmComment #16
eule commentedThis issue (feature) is now 2 years old! D8 is out..and nothing is done...simply...thats the drupal way..late always tooo late
Comment #17
xjmSince this breaks strings, it's not eligible for 8.0.x at this point. However, a site-specific workaround in that case might be to provide a custom translation of the string that adds the nofollow.
@eule, your comment is not helpful. You can help this issue make progress by testing the actual patch provided and confirming whether that works. See https://www.drupal.org/patch/apply for help on how to apply patches.
It sounds like we should also remove the user login block change from this patch according to @scor's review. https://www.drupal.org/node/707484 explains how you can create a new patch, and https://www.drupal.org/node/1488712 explains how you can create an interdiff to show a change from a previous patch. You can also come to the Drupal core mentoring hours to get help with contributing to a core issue. See https://www.drupal.org/core-mentoring for more information.
Finally, @eule, since we may not make the user login block change in core, I think a good way to provide a fix for the user login block would be to create a contributed or custom module that provided an alternate user login block with the nofollow option. Then sites that wanted the nofollow could place that block instead.
Thanks!
Comment #20
andraeray commentedI accomplished it this way by using a preprocess_page hook in template.php. It checks requested URL to see if it has /user/ at the beginning.
Comment #22
b.livonnen commentedUsefull piece of code @AndraeRay
You can modify it this way to handle sites in subfolders as well :
Comment #25
Pejka commentedYou can use this piece of code in html.html.twig
{% set url = url('') %}
{% if 'user' in url|render|render %}
meta name="robots" content="noindex" (add <> since those are hidden by drupal.org editor)
{% endif %}
What I suggest is to install drupal/rename_admin_paths module and change /user/* url. After that configure this code to check for new keyword in url string.
Be aware that in order for this to work, your url should not be in robots.txt: https://developers.google.com/search/reference/robots_meta_tag
Comment #27
caspervoogt commentedNone of the code suggestions in the thread above worked for me. I solved it using metatag_routes.
Comment #29
bbombachiniIn D8 you can also do it through a hook_page_attachments_alter and use path.matcher service to add to all /user pages like this:
Comment #32
junglehttps://www.drupal.org/project/metatag_routes mentioned in #27 by @caspervoogt works as expected, and I do not think we should bring this into the core. So let's close this. Thanks all for your efforts!