The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. On-Page / Site Optimization
    4. How do i block an entire category/directory with robots.txt?

    How do i block an entire category/directory with robots.txt?

    On-Page / Site Optimization
    3 2 2.7k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bricerhodes
      bricerhodes last edited by

      Anyone has any idea how to block an entire product category, including all the products in that category using the robots.txt file? I'm using woocommerce in wordpress and i'd like to prevent bots from crawling every single one of products urls for now.

      The confusing part right now is that i have several different url structures linking to every single one of my products for example www.mystore.com/all-products, www.mystore.com/product-category, etc etc.

      I'm not really sure how i'd type it into the robots.txt file, or where to place the file.

      any help would be appreciated thanks

      1 Reply Last reply Reply Quote 0
      • LynnPatchett
        LynnPatchett last edited by

        Hi

        This should do it, you place the robots.txt in the root directory of your site.

        User-agent: * Disallow: /product-category/

        You can check out some more examples here: http://www.seomoz.org/learn-seo/robotstxt

        As for the multiple urls linking to the same pages, you will just need to check all possible variants and make sure you have them covered in the robots.txt file.

        Google webmaster tools has a page where you can use to check if the robots.txt file is doing what you expect it to do (under Health -> Blocked Urls).

        It might be easier to block the pages with a meta tag as described in the link above if you are running a plugin allowing this, that should take care of all the different url structures also.

        Hope that helps!

        1 Reply Last reply Reply Quote 3
        • bricerhodes
          bricerhodes last edited by

          Thanks for the detailed answer, i will give it a try!

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          • Hi, Is it bad SEO practice to create URLs with #ancor suffix?? lik http://www.diamonds-usa.com/category/diamond-engagement-rings/40-engagement-rings-w-side-stones.aspx#ancor
            ThompsonPaul
            ThompsonPaul
            1
            2
            70

          • When You Add a Robots.txt file to a website to block certain URLs, do they disappear from Google's index?
            Saijo.George
            Saijo.George
            0
            3
            205

          • Site Maps / Robots.txt etc
            LockCity
            LockCity
            0
            3
            120

          • Duplicate content http:// something .com and http:// something .com/
            BlueprintMarketing
            BlueprintMarketing
            0
            6
            771

          • New CMS system - 100,000 old urls - use robots.txt to block?
            Blenny
            Blenny
            0
            8
            745

          • In my report of my website it was indicated that I had 19 links/locations blocked by meta-robots. What does this mean and how do I fix it. My website is a Wordpress website.
            KeriMorgret
            KeriMorgret
            0
            3
            501

          • Why does SEOmoz use /blog/content-title vs /category/content-title? Any difference?
            conquerapathy-64412
            conquerapathy-64412
            0
            2
            854

          • What reasons exist to use noindex / robots.txt?
            KeriMorgret
            KeriMorgret
            0
            5
            1.2k

          Get started with Moz Pro!

          Unlock the power of advanced SEO tools and data-driven insights.

          Start my free trial
          Products
          • Moz Pro
          • Moz Local
          • Moz API
          • Moz Data
          • STAT
          • Product Updates
          Moz Solutions
          • SMB Solutions
          • Agency Solutions
          • Enterprise Solutions
          • Digital Marketers
          Free SEO Tools
          • Domain Authority Checker
          • Link Explorer
          • Keyword Explorer
          • Competitive Research
          • Brand Authority Checker
          • Local Citation Checker
          • MozBar Extension
          • MozCast
          Resources
          • Blog
          • SEO Learning Center
          • Help Hub
          • Beginner's Guide to SEO
          • How-to Guides
          • Moz Academy
          • API Docs
          About Moz
          • About
          • Team
          • Careers
          • Contact
          Why Moz
          • Case Studies
          • Testimonials
          Get Involved
          • Become an Affiliate
          • MozCon
          • Webinars
          • Practical Marketer Series
          • MozPod
          Connect with us

          Contact the Help team

          Join our newsletter
          Moz logo
          © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
          • Accessibility
          • Terms of Use
          • Privacy