phpcms v9 单页面调用seo META Title和seo META Keywords
如果在不需要seo自动优化,则可以把header中的<head>标签直接复制到单页面:
<title>{if isset($SEO['title']) && !empty($SEO['title'])}{$SEO['title']}{/if}{$SEO['site_title']}</title>
<meta name="keywords" content="{$SEO['keyword']}">
<meta name="description" content="{$SEO['description']}">
修改成:
<title>“需要添加的标题”</title>
<meta name="keywords" content="需要添加的关键字">
<meta name="description" content="需要添加的描述">
<!--将需要添加的东西替换成需要的内容www.ctvol.com-->
将此段{template "content","header"}替换成写好的<head>内容
如果不固定,则需要修改phpcms的seo变量:
大家应该都是在header头文件里写上
{if isset($SEO['title']) && !empty($SEO['title'])}{$SEO['title']}{/if}{$SEO['site_title']}
这个$SEO的变量是在 /phpcms/modules/content/index.php
直接搜索 $SEO = seo ,发现这里的$SEO变量如下:
$SEO = seo($siteid, 0, $title,$setting[‘meta_description’],$keywords);
seo这个函数所在文件/phpcms/libs/functions/global.func.php
这个函数的声明为:
function seo($siteid, $catid = ”, $title = ”, $description = ”, $keyword = ”)
研究一下它的定义,发现第二个参数是调用栏目seo META Title和seo META Keywords使用的,如果是0就不调用。
修改方法。
将上面$SEO的赋值写成
$SEO = seo($siteid, $catid, $title,$setting[‘meta_description’],$keywords);
在网上查了一下,还要修改/phpcms/modules/content/class/html.class.php里面的单页面$SEO变量(这个应该是生成静态化用的。)。
找到有注释标明那些是单页面的代码一样修改为:
$SEO = seo($siteid, $catid, $title,$setting[‘meta_description’],$keywords);
关于标题有重复,可以修改一下seo META Title这样看起来会好看点。
还有标题后面多了一个杠。
seo这个函数所在文件/phpcms/libs/functions/global.func.php里面:
$seo ['title'] = (isset ( $title ) && ! empty ( $title ) ? $title : '') . (isset ( $cat ['setting'] ['meta_title'] ) && ! empty ( $cat ['setting'] ['meta_title'] ) ? $cat ['setting'] ['meta_title'] . ' - ' : (isset ( $cat ['catname'] ) && ! empty ( $cat ['catname'] ) ? $cat ['catname'] . ' - ' : ''));
修改成:
$seo ['title'] = (isset ( $title ) && ! empty ( $title ) ? $title . '_' : '') . (isset ( $cat ['setting'] ['meta_title'] ) && ! empty ( $cat ['setting'] ['meta_title'] ) ? $cat ['setting'] ['meta_title'] : (isset ( $cat ['catname'] ) && ! empty ( $cat ['catname'] ) ? $cat ['catname']: ''));
以上的其实也太长了,嫌麻烦的可以修改一下。
如果想按着自己的思路走,则直接固定,这样百度搜索引擎来说相对友好一点。
该文章属于:计算机技术网原创
转载请注明标题:phpcms单网页seo标题解决方法-计算机技术网
转载请注明出处:https://www.ctvol.com/seoomethods/2174.html