博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Use Categories in Product URLs for Magento SEO without Duplicate Content
阅读量:4200 次
发布时间:2019-05-26

本文共 4655 字,大约阅读时间需要 15 分钟。

Use Categories in Product URLs for Magento SEO without Duplicate Content

Magento Open Source eCommerce logo Magento provides the option to use categories in your product URLs for the search engine optimization benefits it brings, but they’ve implemented it in a very unusual way. Basically, if you enable this option, you’ll end up with at least 4 URLs per product. Once people realize it, this often raises a number of concerns including possible duplicate content penalty from Google, fractured link juice for product pages, frustrated admins, etc.

With , I decided disabling the feature was an unacceptable solution, and took the challenge.

 

First you have to enable the feature under System > Configuration > Catalog > Search Engine Optimization .

Use categories path for product URLs – This determines how the URL Rewrites autogenerate. If you choose Yes, the URL rewrite for products will include the associated category, and a separate rewrite will generate for each associated category. If you choose No, the URL Rewrites will include only the product name, and there will be only one rewrite, regardless of how many categories the product is associated to.

Once this feature is enabled, you’ll be to use any of these URLs to visit the same product page:

  • /catalog/product/view/id/<product_id>

    example: http://www.domain.tld/catalog/product/view/id/6
    Internal to Magento; never actually exposed.

  • /catalog/product/view/id/<product_id>/category/<category_id>

    example: http://www.domain.tld/catalog/product/view/id/6/category/10
    Internal to Magento; never actually exposed.

  • /name-of-product

    example: http://www.domain.tld/super-dee-duper-tent-1000-olive
    Normally used on the front page, in content blocks, or anywhere other than a category page. This is because without being on a category page, Magento doesn’t know which category would be appropriate to display in the URL (since it provides the ability to have multiple categories per product). Therefore it opts to not display any category at all. A bad decision in my opinion.

  • /category-1/sub-category-1/name-of-product

    example: http://www.domain.tld/sporting-goods/camping-hiking/super-dee-duper-tent-1000-olive
    Used from category pages.

  • /category-2/name-of-product

    example: http://www.domain.tld/affordable-housing/super-dee-duper-tent-1000-olive
    Used from category pages.

  • etc.

    Depending on how many categories per product.

Personally, I don’t like my products having multiple URLs. Between the front page and the category pages, two separate URLs are introduced to GoogleBot as it crawls through the pages. Even though , which page do you want to appear in Google SERPs? Which one do you want your customers to link at? You’re splitting your link juice and causing confusion.

When I saw this feature for the first time, all I really expected was a single URL like:

http://www.domain.tld/sporting-goods/camping-hiking/super-dee-duper-tent-1000-olive

Well, it took about four hours to find, but I finally came up with a patch to Magento core that delivers this result. Check it out below in unified diff / patch file format:

Index: app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php =================================================================== --- app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php	(revision 2102) +++ app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product/Collection.php	(working copy) @@ -553,7 +553,11 @@                  ->from($this->getTable('core/url_rewrite'), array('product_id', 'request_path'))                  ->where('store_id=?', Mage::app()->getStore()->getId())                  ->where('is_system=?', 1) -                ->where('category_id=? OR category_id is NULL', $this->_urlRewriteCategory) +//                excluding this clause to facilitate one URL per product, and one that includes the category +//                if a product has multiple categories, the first one (by category_id) will be used +//                in most cases you'll probably only have one category because you only want one page per product for SEO reasons +//                for maximum link juice, no possibility of duplicate content, and a less confusing store +//                ->where('category_id=? OR category_id is NULL', $this->_urlRewriteCategory)                  ->where('product_id IN(?)', $productIds)                  ->order('category_id DESC'); // more priority is data with category id              $urlRewrites = array();

In my setup, each product only has one category. Although this will also work if you specify multiple categories per product, you won’t have complete control over which category is used for the official link.

转载地址:http://edcli.baihongyu.com/

你可能感兴趣的文章
【HTML5/CSS/JS】开发跨平台应用工具的选择(三)
查看>>
【心灵鸡汤】Give it five minutes不要让一个好主意随风而去
查看>>
【React Native】Invariant Violation: Application AwesomeProject has not been registered
查看>>
【ReactNative】真机上无法调试 could not connect to development server
查看>>
【XCode 4.6】常用快捷键 特别是格式化代码ctrl+i
查看>>
【iOS游戏开发】icon那点事 之 实际应用(二)
查看>>
【iOS游戏开发】icon那点事 之 图标设计(三)
查看>>
【IOS游戏开发】之测试发布(Distribution)
查看>>
【IOS游戏开发】之IPA破解原理
查看>>
【一天一道LeetCode】#45. Jump Game II
查看>>
【一天一道LeetCode】#46. Permutations
查看>>
【一天一道LeetCode】#47. Permutations II
查看>>
【一天一道LeetCode】#48. Rotate Image
查看>>
【一天一道LeetCode】#56. Merge Intervals
查看>>
【一天一道LeetCode】#57. Insert Interval
查看>>
【一天一道LeetCode】#58. Length of Last Word
查看>>
【一天一道LeetCode】#59. Spiral Matrix II
查看>>
【一天一道LeetCode】#30. Substring with Concatenation of All Words
查看>>
【一天一道LeetCode】#60. Permutation Sequence.
查看>>
【一天一道LeetCode】#62. Unique Paths
查看>>