JavaScript链接和SEO?

Šim*_*das 6 javascript seo

首先,看一下这个演示页面:http://vidasp.net/tinydemos/seo-javascript-links.html

页面上有一个菜单,单击菜单项将显示指向其他网页(属于网站的一部分)的各种链接.链接URL采用以下格式:

www . foo . com / articles / XXX / descriptive-title-of-the-article
Run Code Online (Sandbox Code Playgroud)

...其中XXX是给定文章的三位数ID.

这一切似乎都没问题,但有一个问题:所有这些链接都是通过JavaScript动态创建的.看一下源代码 - 在页面底部有一个JavaScript变量(db变量),它包含用于生成链接的所有数据.

我使用的是JavaScript,因为我不想使用服务器端.我假设,在这种情况下,我必须将数据存储在SQL数据库中,然后使用C#/ PHP/etc.生成链接.但是,这对我来说不是一个选择 - 我严格地面向客户端.

顺便说一句,如果你想看到更精细的JavaScript生成链接演示,请访问这里 - http://www.w3viewer.com - 该页面上有大约400个链接,所有链接都是通过JavaScript动态生成的.

问题:

现在,我喜欢这种方法 - 使用JavaScript生成链接 - 但是,这种方法的结果是搜索引擎爬虫不会注册任何这些链接 - 他们只是"看到"没有链接的空白页面(这是一个SEO灾难,我假设).

所以,我想知道,我怎么能优化这种方法?

更新(后续问题):

我无法使用Google站点地图告诉Google抓取工具网站上存在哪些网页?这样我就可以保持头版(上面的演示)不受影响(没有静态链接),抓取工具会使用站点地图抓取我网站的所有网页.

我对谷歌站点地图还不了解,但我想知道为什么没有人建议它们.他们可以解决我的问题吗?

Sin*_*nür 3

看起来您真正需要做的是在部署之前使用模板生成 HTML,例如Template::Toolkit 's ttree。然后,您可以将数据库保留在开发计算机上。不需要 JavaScript。

这是一个简化的示例:

[%- 
db = {
    Foo => [
        { id => "001", title => "First article" },
        { id => "002", title => "Another article" },
        { id => "003", title => "Yet another article" },
    ], 
    Bar => [
        { id => "004", title => "First article in this category" },
        { id => "005", title => "Another article in bar" },
        { id => "006", title => "Third bar article" },
    ],
    Baz => [
        { id => "007", title => "Baz article No. 1" },
        { id => "008", title => "The second Baz article" },
        { id => "009", title => "The last article" },
    ],
}
-%]

[%- FOR category IN db.keys -%]

<h2>[%- category -%]</h2>

[%- articles = db.$category -%]

[%- FOR article IN articles -%]

<p>Article: <a href="http://www.example.com/articles/[%- article.id -%]/">
    [%- article.title -%]</a></p>

[%- END -%]
[%- END -%]
Run Code Online (Sandbox Code Playgroud)
C:\Temp> tpage t.html
<h2>Bar</h2>

<p>Article: <a href="http://www.example.com/articles/004">First article in this
category</a></p>

<p>Article: <a href="http://www.example.com/articles/005">Another article in bar
</a></p>

<p>Article: <a href="http://www.example.com/articles/006">Third bar article</a><
/p>

<h2>Baz</h2>

<p>Article: <a href="http://www.example.com/articles/007">Baz article No. 1</a><
/p> 
Run Code Online (Sandbox Code Playgroud)

……