由于自己的站用了大量的属性过滤功能.虽然这样做,用户体验非常的好.但是,牺牲了seo的性能.

首先是层导航页面的url并不友好.再次是层导航页面的meta等信息也不好书写..

url的问题.发现可以使用插件实现. 下面的文章,是我google以后,发现已经解决的问题.(原文请点击这里)

english to chinese:

总所周知,magento的seo性能不是非常完美.这就是为什么我的代码会让seo更好的原因:)

我的这个方案,使magento不管多少个分类子页面的标题(title)和元标记(meta)在使用层导航的情况下,title和meta都会自行更改.(默认情况下,层导航和其分类的meta和title都是一样的,这就是google参考重复页面的常见原因之一.)

首先,我们先创建这个文件:

app/code/local/Mage/Page/Block/Html/Head.php

使用这个方法(method)时,所有的活动的过滤器的名字(也就是选了层导航的属性)和当前层导航的值传递给$layerFilters.
这个方法(method)支持排序(order by *)和分页.

public $layerFilters;
public $currentFilters;
public $orderBy;
public $currentPage;
public function getLayersMeta(){

$this->layerFilters = '';
$state_block = $this->getLayout()->createBlock("catalog/layer_state");
$this->currentFilters = $state_block->getActiveFilters();

if(!empty($this->currentFilters)) {
foreach($this->currentFilters as $filter) {

$this->layerFilters .= ($this->layerFilters!='') ? ', '.$filter->getName() : $filter->getName();

$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $filter->getFilter()->getRequestVar());
foreach($attribute->getSource()->getAllOptions(true, true) as $option) {
if($filter->getValue() == $option['value']) {
$this->layerFilters .= ' - '.strtr($option['label'],array('"'=>"''"));
}
}
}
$this->layerFilters = ($this->layerFilters!='') ? $this->__('Shopping by: ').$this->layerFilters.' - ' : '';
}

$this->orderBy = '';

if($this->getRequest()->getParam('order') && $this->getRequest()->getParam('dir')) {
$this->orderBy .= $this->__('Sort by ').$this->__(htmlspecialchars($this->getRequest()->getParam('order')));
$this->orderBy .= (htmlspecialchars($this->getRequest()->getParam('dir')) == 'asc') ? ', '.$this->__('ascending') : ', '.$this->__('descending');
}

if($this->getRequest()->getParam('limit') && is_numeric($this->getRequest()->getParam('limit'))) {
$this->orderBy .= (($this->orderBy!='') ? ', ' : $this->__('show')).' '.$this->getRequest()->getParam('limit').' '.$this->__('per page');
}

if($this->getRequest()->getParam('p') && is_numeric($this->getRequest()->getParam('p'))) {
$this->currentPage = $this->__('Page').' '.$this->getRequest()->getParam('p').' - ';
}

$this->orderBy = ($this->orderBy!='') ? $this->orderBy.' - ' : '';

return $this->layerFilters.$this->orderBy.$this->currentPage;
}

下一步,将两种方法在同一个文件((getDescription() oraz getTitle()))以这种方式进行修改:

public function getDescription()
{
if (empty($this->_data['description'])) {
$this->_data['description'] = Mage::getStoreConfig('design/head/default_description');
}
return $this->getLayersMeta().$this->_data['description'];
}
public function getTitle()
{
if (empty($this->_data['title'])) {
$this->_data['title'] = $this->getDefaultTitle();
}
return $this->getLayersMeta().htmlspecialchars(html_entity_decode(trim($this->_data['title']), ENT_QUOTES, 'UTF-8'));
}

lol.现在看我们的层导航页面.将会得到第一无二的title.
以上代码已经通过本人亲自测试通过.完美的title.赶快根据上面的代码自定义出更cool的title吧…
如果对代码有疑问和建议,检查查看原文并咨询作者:http://www.designend.net/en/webmaster-blog,magento-google-seo-friendly-layered-navigation
如果想加强magento的seo性能,建议看Magento seo优化手册.

关于作者

专注于电商,magentochina站长
shuai.zend一共有82篇博文

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

TOP Online Store
1.Girls' Generation, a Fantasy Jewelry online Store. Nobody Can Keep Away From the Beauty:tiffany ca 2.China Wholesale Electronics:China Wholesale Electronics 3.The android phone is best:Android sale.The Android Ice cream sandwich well be best Android OS. 4.R4 3DS for sale:R4 ds shops,and support Japanese R4:R4 販売. 5.fashion bag:armani watches and MBT shoes.
R4 V1.4.2 and your R4i Gold 1.4.2 and R4i GOLD 3DS card V1.4.2 can not work on it.
Please update your R4i Gold 1.4.2 and R4i GOLD 3DS card V1.4.2 card with this patch. Please read readme.txt attached firstly.Just do as the procedures listed in readme.