PJBlog3 SEO,title/keywords/description优化实现

已为老胡 2008-12-23 PM 2194℃ 0条

    相对于PJBLOG v2.7来说,PJBLOG3最大改进之处在于文章页的全静态化处理,大大提升了网站整体性能。下面我们来看下会针对 PJBLOG3 如何进行搜索引擎优化。这里主要讲解下全静态化模式下的更改,如果你使用的是半静态模式请参考PJBLOG v2.7进行更改,有不明白的地方可以通过E-mail 与我联系。

    一.PJBlog3 页面标题搜索引擎优化程序实现(分类页面标题与标签页面标题)
    -header.asp

If InStr(Replace(LCase(Request.ServerVariables("URL")), "", "/"), "/article.asp") = 0 Then
getBlogHead BlogTitle, "", -1
End If

    这句代码是判断URL中是否包含字符串 "/article.asp" 如果没有则执行代码,这正是我们修改的地方,将它替换为以下代码:

'如果url中不包含字符串"/article.asp",处理除文章显示外的其它页面标题
If inStr(Replace(Lcase(Request.ServerVariables("URL")),"","/"),"/article.asp") = 0 Then
Dim strTag
Dim intCateID
Dim objCategory
strTag = Request.QueryString("tag")
intCateID = Request.QueryString("cateID")
If strTag<>"" Then BlogTitle = strTag & "-" & BlogTitle
If IsInteger(intCateID) Then
Set objCategory = New Category
objCategory.load(intCateID)
BlogTitle = objCategory.cate_Name & "-" & BlogTitle
getBlogHead BlogTitle,objCategory.cate_Name,intCateID
Set objCategory=Nothing
Else
getBlogHead BlogTitle,"",-1
End If
End If
If InStr(Replace(LCase(Request.ServerVariables("URL")), "", "/"), "/article.asp") = 0 Then
getBlogHead BlogTitle, "", -1
End If

    这句代码是判断URL中是否包含字符串 "/article.asp" 如果没有则执行代码,这正是我们修改的地方,将它替换为以下代码:

'如果url中不包含字符串"/article.asp",处理除文章显示外的其它页面标题
If inStr(Replace(Lcase(Request.ServerVariables("URL")),"","/"),"/article.asp") = 0 Then
Dim strTag
Dim intCateID
Dim objCategory
strTag = Request.QueryString("tag")
intCateID = Request.QueryString("cateID")
If strTag<>"" Then BlogTitle = strTag & "-" & BlogTitle
If IsInteger(intCateID) Then
Set objCategory = New Category
objCategory.load(intCateID)
BlogTitle = objCategory.cate_Name & "-" & BlogTitle
getBlogHead BlogTitle,objCategory.cate_Name,intCateID
Set objCategory=Nothing
Else
getBlogHead BlogTitle,"",-1
End If
End If

    二.meta 标签优化(文章显示页面)
    -classcls_logAction.asp
    1、找到1044行:
Temp1 = Replace(Temp1, "<$comment$>", ShowComm(LogID, comDesc, log_View("log_DisComment"), True, log_View("log_IsShow")))

    将以下代码插入到此语句下方新行中

' 文章关键字及描述值设定
Dim objTag, objRe
Set objTag = New tag
Dim strKeywords, strDescription
strKeywords = objTag.filterHTML(log_View("log_tag"))
strDescription = log_View("log_Intro")
Set objTag = Nothing
strKeywords = Replace(strKeywords," , Set objRe=new RegExp
objRe.IgnoreCase =True
objRe.Global=True
objRe.Pattern = "<.*?rel.*?>(.*?)</.*?>" ' 过滤HTML标签
strKeywords = objRe.Replace(strKeywords,"$1") & "," & log_View("log_Title")
objRe.Pattern = "[img.*?].*?[/img]" ' UBB标签[IMG]特别处理
strDescription = objRe.Replace(strDescription,"")
objRe.Pattern = "[(w+)[^[]]*]([^[]]*)[/1]" ' 过滤UBB标签
strDescription = objRe.Replace(strDescription,"$2") & "," & log_View("log_Title")
objRe.Pattern = "<(.[^>]*)>" ' 过滤HTML标签
strDescription = objRe.Replace(strDescription,"")
Set objRe = Nothing
Temp1 = Replace(Temp1, "<$keywords$>", strKeywords)
Temp1 = Replace(Temp1, "<$description$>", strDescription)

    2、文章静态页面模板修改
-Templatestatic.htm

    找到以下语句

    将以上 meta 标签替换为
" />
" />
    1、找到1044行:
Temp1 = Replace(Temp1, "<$comment$>", ShowComm(LogID, comDesc, log_View("log_DisComment"), True, log_View("log_IsShow")))

    将以下代码插入到此语句下方新行中

' 文章关键字及描述值设定
Dim objTag, objRe
Set objTag = New tag
Dim strKeywords, strDescription
strKeywords = objTag.filterHTML(log_View("log_tag"))
strDescription = log_View("log_Intro")
Set objTag = Nothing
strKeywords = Replace(strKeywords," , Set objRe=new RegExp
objRe.IgnoreCase =True
objRe.Global=True
objRe.Pattern = "<.*?rel.*?>(.*?)</.*?>" ' 过滤HTML标签
strKeywords = objRe.Replace(strKeywords,"$1") & "," & log_View("log_Title")
objRe.Pattern = "[img.*?].*?[/img]" ' UBB标签[IMG]特别处理
strDescription = objRe.Replace(strDescription,"")
objRe.Pattern = "[(w+)[^[]]*]([^[]]*)[/1]" ' 过滤UBB标签
strDescription = objRe.Replace(strDescription,"$2") & "," & log_View("log_Title")
objRe.Pattern = "<(.[^>]*)>" ' 过滤HTML标签
strDescription = objRe.Replace(strDescription,"")
Set objRe = Nothing
Temp1 = Replace(Temp1, "<$keywords$>", strKeywords)
Temp1 = Replace(Temp1, "<$description$>", strDescription)

    2、文章静态页面模板修改
-Templatestatic.htm

    找到以下语句

    将以上 meta 标签替换为
" />
" />

标签: PJblog

非特殊说明,本博所有文章均为博主原创。

评论啦~