您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程

ecshop怎么做SEO优化

含玉2024-12-19Ecshop商城教程已有人查阅

导读一、完全自定义页面titile,完全抛弃Ecshop定义的页面title格式:[产品名称]_[分类名]_[网店名称]-Powered by ECShop

一、完全自定义页面titile,完全抛弃Ecshop定义的页面title格式:[产品名称]_[分类名]_[网店名称]-Powered by ECShop
1、分析:大家都知道,titile,kewords,description在SEO中的基础性和重要性,但是ECshop官方给出的titile实现方 出现很多类似或相同的页面title,另外还有部分页面无法自定义kewords和 description。在此本人给出了完全自定义的方法,其实方法很简单的,只要稍微懂得一点点代码的都会。
2、修改包括:品牌页,商品页,商品分类页,文章页,文章分类页
3、修改涉及的页面: 品牌页(增加title,keywords和description):brand.php、admin\brand.php、 admin\templates\brand_info.htm
商品页(增加title):goods.php、admin\goods.php、 admin\templates\goods_info.htm
商品分类页(增加title):category.php、admin\category.php、 admin\templates\category_info.htm
文章页面(增加title):article.php、admin\article.php、 admin\templates\article_info.htm
文章分类页(增加title):article_cat.php、admin\articlecat.php、 admin\templates\articlecat_info.htm
4、具体修改:现在就拿品牌页的修改来举例:
1) 首先是修改数据库,未安装的在数据库结构文件install\data\structure.sql中改,已安装的手动在安装后的数据库中改,对brand表增加brand_title、brand_keywords和brand_description等字段
2) 接着修改admin\brand.php,这个文件是管理员后台文件
·88行:
$sql = "INSERT INTO ".$ecs->table('brand')."(brand_name, site_url, brand_desc, brand_logo, is_show, sort_order) "."VALUES ('$_POST[brand_name]', '$site_url', '$_POST[brand_desc]', '$img_name', '$is_show', '$_POST[sort_order]')";
$db->query($sql);
改为:
$sql = "INSERT INTO ".$ecs->table('brand')."(brand_name, site_url, brand_desc, brand_title, brand_keywords, brand_description,brand_logo, is_show, sort_order) "."VALUES ('$_POST[brand_name]', '$site_url', '$_POST[brand_desc]', '$_POST[brand_title]', '$_POST[brand_keywords]', '$_POST[brand_description]', '$img_name', '$is_show', '$_POST[sort_order]')";
$db->query($sql);
·113行
admin_priv('brand_manage');
$sql = "SELECT brand_id, brand_name, site_url, brand_logo, brand_desc, brand_logo, is_show, sort_order "."FROM " .$ecs->table('brand'). " WHERE brand_id='$_REQUEST[id]'";
$brand = $db->GetRow($sql);
改为:
admin_priv('brand_manage');
$sql = "SELECT brand_id, brand_name, site_url, brand_logo, brand_desc,brand_title, brand_keywords, brand_description,brand_logo, is_show, sort_order "."FROM " .$ecs->table('brand'). " WHERE brand_id='$_REQUEST[id]'";
$brand = $db->GetRow($sql);
·151行
$img_name = basename($image->upload_image($_FILES['brand_logo'],'brandlogo'));
$param = "brand_name = '$_POST[brand_name]', site_url='$site_url', brand_desc='$_POST[brand_desc]', is_show='$is_show', sort_order='$_POST[sort_order]' ";
改为:
$img_name = basename($image->upload_image($_FILES['brand_logo'],'brandlogo'));
$param = "brand_name = '$_POST[brand_name]', site_url='$site_url', brand_desc='$_POST[brand_desc]',brand_title='$_POST[brand_title]', brand_keywords='$_POST[brand_keywords]', brand_description='$_POST[brand_description]',is_show='$is_show', sort_order='$_POST[sort_order]' ";
3)紧接着修改admin\templates\brand_info.htm
·在第31行插入:
<tr>
<td class="label">页面标题</td>
<td><input type="text" name="brand_title" maxlength="120" value="{$brand.brand_title|escape}" /></td>
</tr>
<tr>
<td class="label">页面关键词</td>
<td><input type="text" name="brand_keywords" maxlength="120" value="{$brand.brand_keywords|escape}" /></td>
</tr>
<tr>
<td class="label">页面描述</td>
<td><textarea name="brand_description" cols="60" rows="4" >{$brand.brand_description}</textarea></td>
</tr>
4) 之后修改brand.php ,这个文件是前台控制文件
·93、94行
$smarty->assign('keywords', htmlspecialchars($brand_info['brand_desc']));
$smarty->assign('description', htmlspecialchars($brand_info['brand_desc']));
改为:
$smarty->assign('page_title', htmlspecialchars($brand_info['brand_title']));
$smarty->assign('keywords', htmlspecialchars($brand_info['brand_keywords']));
$smarty->assign('description', htmlspecialchars($brand_info['brand_description']));
就这样,品牌页的title,keywords和description全部实现了自定义,商品页、商品分类页、文章页、文章分类页都只需要增加title,修改方法与品牌页(brand)完全相同,想怎么改完全由你自己决定。
二、修改余下的页面title格式
1、分析:Ecshop每个页面都包含了商店标题,不利于SE,也不够个性化,前面已将重要的页面修改成有利于SE的,剩下的可以改你自己喜欢的格式,比如:首页格式:商店标题_商店名称;商品名称_分类名称_商店名
2、修改文件includes\lib_main.php
3、具体修改:
·142行
$page_title = $GLOBALS['_CFG']['shop_title'] . ' - ' . 'Powered by ECShop';
改为:
$page_title = $GLOBALS['_CFG']['shop_name'];
·在241行插入:
if ($filename == 'index')
$page_title=$GLOBALS['_CFG']['shop_title'] . '_' . $page_title;
三、404优化,众所周知,404出错处理不当对搜索引擎收录的影响是非常大的,ecshop在这方面做得非常的差,甚至导致了很多的站不被搜索引擎收录。
1、分析:ECSHOP程序文件category.php及goods.php等页面多处存在以下这样的代码:ecs_header("Location: ./\n");exit;以上代码的意思是,如果找不到当前ID下的分类或者商品,则跳转到网站首页。这样子跳转,返回的HTTP代码将会是302,表明此页面信息暂时性转移,这类跳转代码很容易引起搜索引擎封杀,因此我们需要作出404的优化。
2、修改涉及的文件:article.php,article_cat.php,brand.php,category.php,comment.php,goods.php,topic.php
3、修改方法:将以上7个文件中的 ecs_header("Location: ./\n"); 全部改为 ecs_header("HTTP/1.0 404 Not Found"); $smarty->display('404_error.html');
同时在模板文件中加入404_error.html文件

本文标签:

很赞哦! ()

相关源码

  • (自适应)文案文档作文写作word资源网站模板下载本模板基于PbootCMS系统深度开发,针对电影解说、文案分享类网站的特殊需求设计。采用响应式布局技术,确保在手机端和桌面端都能呈现专业的内容展示效果,帮助运营者高效管理影视解说资源。查看源码
  • (自适应)英文绿色精密模具零件加工五金零件pbootcms外贸网站模板本模板基于PbootCMS开发,为五金零件、精密模具加工等英文外贸企业设计。采用响应式布局,适配各类移动设备,是五金零件企业开展国际贸易的专业展示平台。查看源码
  • (响应式H5)帝国cms7.5文章新闻博客模板带会员中心本模板基于帝国CMS内核开发,为新闻资讯、个人博客及作品展示类网站设计。采用响应式布局技术,确保在手机、平板和电脑等不同设备上都能获得良好的浏览体验。查看源码
  • (PC+WAP)家居装饰家装建材营销型网站pbootcms模板下载本模板基于PbootCMS开发,主要服务于家居装饰、建材及相关行业。采用现代化设计风格,同时适配PC和移动设备访问。模板结构清晰,突出展示家装案例和建材产品,帮助企业在线上建立专业形象,有效展示产品与服务优势。查看源码
  • (自适应)宽屏农业机械农耕设备类网站pbootcms模板免费下载为农机企业打造的现代化响应式网站模板,自动适配电脑、平板和手机,浏览体验一致,独立页面SEO设置,提升搜索引擎可见度。查看源码
  • 响应式WordPress简约博客主题Alt_BlogAlt_Blog主题该模板为博客内容展示设计,采用简约现代的风格理念,打造清晰的内容呈现平台。响应式布局确保在不同设备上都能获得良好的浏览体验,帮助博主更好地展示和分享内容。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐