framework icon indicating copy to clipboard operation
framework copied to clipboard

Prevent crawling of nojs pages

Open dcsjapan opened this issue 10 years ago • 24 comments

Reported by @dav-is via Gitter chat:

It looks like Google crawled the community site while it was experiencing JS issues and ended up recording some nojs URLs.

nojs

Some sort of countermeasures are needed to keep search engines away from these URLs.

It might also be a good idea to use Google web tools to get the site recrawled, so people won't follow the links to these URLs.

dcsjapan avatar Apr 04 '16 04:04 dcsjapan

Seems like a issue with the server configuration (and possibly robots.txt file) then a issue with flarum itself.. In any case, this post looks helpful

robots.txt

Disallow: /*?nojs=1

kulga avatar Apr 04 '16 04:04 kulga

I agree it's not a core issue. But it nicely shows the kind of problems that you get when doing single-page applications... sigh

We can leave this one open as a reminder to fix it, though.

franzliedke avatar Apr 04 '16 06:04 franzliedke

It's the sort of thing that admins won't know to fix unless we tell them.

If the robots.txt syntax suggested by @kulga will do the trick (I hadn't realized robots.txt could be used that way) then this could be handled by a super-slick installer. It could create a robots.txt file containing this line ... problem solved, yes?

If that sounds good, I'll add a note to the installer discussion issue pointing at this one.

dcsjapan avatar Apr 04 '16 06:04 dcsjapan

Couldn't the robot.txt just be placed in flarum's root directory?

dav-is avatar Apr 04 '16 06:04 dav-is

Would that work even if Flarum is installed in a subdirectory? ... I've been under the impression that robots.txt has to be in the web root, or it may be ignored.

Maybe we should just add this to the installation docs, instead? It's a simple enough procedure.

dcsjapan avatar Apr 04 '16 06:04 dcsjapan

What about using canonical URL meta tags?

tobyzerner avatar Apr 04 '16 06:04 tobyzerner

@dcsjapan Yeah. Just looked it up. It has to be at the root

dav-is avatar Apr 04 '16 06:04 dav-is

Another option is Google has settings on crawling with the webmaster tools img

dav-is avatar Apr 04 '16 08:04 dav-is

@dav-is But google probably isn't the only search engine we need to fix this for :)

tobyzerner avatar Apr 04 '16 08:04 tobyzerner

Posting for further reference: https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag

franzliedke avatar Jun 10 '16 15:06 franzliedke

As discussed in flarum/flarum#36, we will build a middleware that sends a special header on these pages.

franzliedke avatar Feb 25 '17 21:02 franzliedke

P.S.: @sijad wants to do this.

franzliedke avatar Feb 25 '17 21:02 franzliedke

@franzliedke is it a good idea to add those tags in app view header?

sijad avatar Feb 26 '17 15:02 sijad

Would it be better to be using a canonical URL meta tag rather than a noindex directive?

tobyzerner avatar Mar 03 '17 01:03 tobyzerner

@tobscure yes it seems a better solutions. should I PR a new one?

sijad avatar Mar 03 '17 05:03 sijad

Or maybe in addition to noindex. Because canonical URL should probably be constructed and set by individual controllers (eg, DiscussionController) rather than just by stripping ?nojs=1 off the end of the current URL...

tobyzerner avatar Mar 03 '17 05:03 tobyzerner

Yes, we should allow controllers to generate a canonical URL, and if we have one, the view will print the meta tag.

franzliedke avatar Mar 03 '17 07:03 franzliedke

Speaking of canonical urls, should the discussion list have a canonical url that doesn't have the post number in it? For example: forum.example/d/5/77 => forum.example/d/5

dav-is avatar Mar 03 '17 18:03 dav-is

not sure I understand @dav-is?

tobyzerner avatar Mar 03 '17 20:03 tobyzerner

Well the page forum.example/d/5 would have the same content at forum.example/d/5/8 and the same content as forum.example/d/5/9. There's overlap in content so should we just remove the post number from the url using the canonical tag? When google crawls, doesn't it scroll down and load all the posts?

dav-is avatar Mar 03 '17 21:03 dav-is