月光博客 » 编程开发 » Z-Blog内链关键字替换插件的修改

Z-Blog内链关键字替换插件的修改

文章正文中的关键字内链插件是SEO常用的工具,越大的网站,越要更加重视内部链接结构的布局。因为良好的内部链接结构可以引导权值的传递,提高收录,提升内页排名。

搜索引擎算法对网页相关性列在很重要的位置,相关性越好的网页,越容易获得排名。所以,整个网站内部应该围绕相关性来规划网站结构。这也是网站结构规划的最基本原则之一。

Z-Blog的关键字内链插件有一些,我使用其中一个名为VKeyWords的插件进行内链替换,但是使用过程中发现一些问题。

该插件使用全部替换的方式,如果文章包含的关键字很多,则会替换非常多的关键字,这属于过度优化,很容易被搜索引擎惩罚,因此,我不得不对该插件进行了一些修改。

由于该插件的替换算法比较独特,不太好修改,因此,我主要修改的地方有以下:

1、关键字最多替换4次(也可以设置为其他的数字)。

2、某个关键字如果在文章里连续出现,则之后出现的均不替换。

经过这些修改,这个插件应该就不会引起过度SEO优化的风险了。

以下为修改方法:

修改function.asp文件的VKeyWords,将该函数后面一部分修改为如下代码:

Dim reg, patt, m, i, p, s, str, url
Dim maxnum, lastmatch
maxnum = 0
lastmatch = ""
str = Content
i = 0
p = 0
s = ""
patt = "<a [^>]*>[^<]*</a>|<[^>]*>|"
For i = 0 To UBound(keys)
patt = patt & keys(i) & "|"
Next
patt = Left(patt, Len(patt) - 1)
Set reg = New RegExp
reg.Global = True
reg.IgnoreCase = True
reg.Pattern = patt
Dim Matches, oMatch, j
Set Matches = reg.Execute(str)
For Each oMatch In Matches
If (Len(oMatch) > 0 And Left(oMatch, 1) <> "<") And maxnum < 4 And lastmatch <> oMatch Then
'不是a标签的时候执行替换
For j = 0 To UBound(keys) - 1
url = ""
If (LCase(oMatch) = LCase(keys(j))) Then
'如果是需要替换的值就替换
url = "<a href=""" & urls(j) & """ title=""" & titles(j) & """ "
If (Windows(j) <> "") Then
url = url & " Target=""" & windows(j) & """ "
End If
url = url & ">" & keys(j) & "</a>"
If (oMatch.FirstIndex > 1) Then
s = s & Mid(str, p + 1, oMatch.FirstIndex - p) & url
Else
s = url
End If
p = oMatch.FirstIndex + Len(keys(j))
j = UBound(keys)
maxnum = maxnum + 1
lastmatch = oMatch
End If
Next
End If
Next
s = s & Right(str, Len(str) - p)
VKeyWords = s

Z-Blog内链关键字替换插件的修改

顶一下 ▲()   踩一下 ▼()

相关文章

发表留言