2

Google says my site is not mobile-friendly, though my site is responsive. see the photo below:

enter image description here

As you see the site is not opening correctly in the preview.

Then I commented out the following sentences in robots.txt, and the problem was solved.

# Disallow: /media/
# Disallow: /modules/
# Disallow: /templates/

enter image description here

I want to know if commenting out these sentences is the wrong way to solve this issue.

What should I do exactly?

2 Answers 2

4

Media and Templates folders shouldn't be disallowed at first place. GoogleBot now requires access to the css/js of a website in order to understand the design and layout of a website, and these two Joomla folders are the location where most of css/js are located.

So it does make sense that Google reported that your website isn't responsive, as it didn't have access to the needed files.

However, if there was a reason for you to disallow media and templates, then you can keep the disallow as is and later on specifically allow access to individual files or subfolders of the above folders.

For more info on how to create your robots.txt read here: http://www.robotstxt.org

For your information, this how the recent robots.txt file that is shipped with Joomla looks like:

# If the Joomla site is installed within a folder 
# eg www.example.com/joomla/ then the robots.txt file 
# MUST be moved to the site root 
# eg www.example.com/robots.txt
# AND the joomla folder name MUST be prefixed to all of the
# paths. 
# eg the Disallow rule for the /administrator/ folder MUST 
# be changed to read 
# Disallow: /joomla/administrator/
#
# For more information about the robots.txt standard, see:
# http://www.robotstxt.org/orig.html
#
# For syntax checking, see:
# http://tool.motoricerca.info/robots-checker.phtml

User-agent: *
Disallow: /administrator/
Disallow: /bin/
Disallow: /cache/
Disallow: /cli/
Disallow: /components/
Disallow: /includes/
Disallow: /installation/
Disallow: /language/
Disallow: /layouts/
Disallow: /libraries/
Disallow: /logs/
Disallow: /modules/
Disallow: /plugins/
Disallow: /tmp/

As an example of what I explained above, you can add below the above lines, specifically allow instructions like so:

Allow: /*.js$
Allow: /*.css$

Allow: /components/com_YOURDESIRED_COMPONENT/css/
Allow: /components/com_YOURDESIRED_COMPONENT/js/
Allow: /components/com_YOURDESIRED_COMPONENT/images/

Allow: /modules/mod_YOURDESIRED_MODULE/css/

Allow: /media/SUBFOLDER/css/A_SPECIFIC_CSS_FILE.css

Allow: /templates/YOURTEMPLATE/css/
Allow: /templates/YOURTEMPLATE/js/
Allow: /templates/YOURTEMPLATE/images/

Use Google Webmasters Tools - robots.txt tester to test your robots instructions: https://support.google.com/webmasters/answer/6062598?hl=en

1

NOTE: Older versions of the joomla robots.txt file included this restriction and it was not possible for Joomla to change that on an update which is why there was a post-installation message on upgrades to inform you of this and the changes that you should make

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.