Use Categories in Product URLs for Magento SEO without Duplicate Content
2011-04-01 15:14
573 查看
Use Categories in Product URLs for Magento SEO without Duplicate Content
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 so
many
people
also
searching
for a clever
solution
, I decided disabling the feature was an unacceptable solution, and took the challenge.
First you have to enable the “Use categories path for product URLs”
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 you may not be seriously penalized for duplicate content
,
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();
[/code]
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.
相关文章推荐
- Get Reviews for a product in magento
- 在Android Manifest中出现Use '$' instead of '.' for inner classes (or use only lowercase letters in pac
- [ERROR]CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 8.1
- CodeSign error: code signing is required for product type 'Application' in SDK 'i
- How to save data in ASCII format in ADS for use in MATLAB
- Delete Product from Cart Programmatically in Magento
- a example for calling java code in javascript use dwr
- 34 Identify two situations in which you can use Data Recovery Advisor for recovery. (Choose two.) A.
- 《How to Use the TimeDistributed Layer for Long Short-Term Memory Networks in Python》学习笔记
- Add custom Field in Order Total for Magento
- How to Collect Errorstacks for use in Diagnosing Performance Issues. (文档 ID 1364257.1)
- How to use udev for Oracle ASM in Oracle Linux 5
- CodeSign error: code signing is required for product type Application in SDK iOS
- How to use "for/" batch command in Dos extention
- [Oracle Mgmt]Use RMAN to Duplicate Database in the Same Host (Based on Windows Platform)
- How to Use the TimeDistributed Layer for Long Short-Term Memory Networks in Python 译文
- ERROR in Cannot use 'in' operator to search for 'providers' in null
- [ngRepeat:dupes] Duplicates in a repeater are not allowed. Use 'track by' expression to specify uni
- A duplicate insert block exists for class "XXX" in the source files (X:\XXX.h, X:\XXX.cpp).
- Use '$' instead of '.' for inner classes (or use only lowercase letters in package names)