0

我的问题是 Google 没有为我的网站编制索引,并且该网站已经启动并运行了 5 周。

不是它不索引我的内部页面,而是它不索引网站本身

当您在 Google 上输入“xyz”作为搜索关键字时,我的网站“ww.xyz.com”将被完全忽略。

该网站是 ajax 驱动的,这是我的配置:

我在服务器根文件夹中有一个robot.txt:

User-agent: *
Disallow: /admin/
Sitemap: http://www.xyz.com/sitemap.xml

我在服务器根文件夹中有一个 sitemap.xml:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="..." xmlns:xsi="..." xsi:schemaLocation="...">
    <url><loc>http://www.xyz.com/</loc></url>
    <url><loc>http://www.xyz.com/index.php?action=link1</loc></url>
    <url><loc>http://www.xyz.com/index.php?action=link2</loc></url>
</urlset>

索引页面如下所示:

<!doctype html>
<html lang="fr">

    <head>

        <title>xyz</title>

        <meta http-equiv= "content-type"      content="text/html;charset=utf-8">
        <meta http-equiv= "Content-Language"  content="fr" >
        <meta name      = "fragment"          content="!">
        <meta name      = "google"            content="notranslate">
        <meta name      = "robots"            content="index,follow"> 
        <meta name      = "Description"       content="...">
        <meta name      = "Keywords"          content="...">

    </head>

    <body>

        <ul id="menu>
            <li id="mylink1">
                <a href="index.php?action=link1">Link 1</a>
            </li>

            <li id="mylink2">
                <a href="index.php?action=link2">Link 2</a>
            </li>
        </ul>

        <div id="content">
            <?php include('ajax.php');?>
        </div>

    </body>

</html>

“ajax.php”文件如下所示:

<script type="text/javascript">
    $('#link1').click(function(e) 
    {   
        e.preventDefault(); 

        $.ajax({
            type:"POST",
            url:"includes/page1.php,
            data:"action=link1",
            complete:function(data){$('#content').html(data.responseText);}
        }); 

    $('#link2').click(function(e) 
    {   
        e.preventDefault(); 

        $.ajax({
            type:"POST",
            url:"includes/page2.php,
            data:"action=link2",
            complete:function(data){$('#content').html(data.responseText);}
        }); 
    });
</script>

假设我们的目标是“includes/page1.php”,这是 page1.php 的内容:

<?php
if($_POST['action']=='link1')
{
    //show the content
    ...
}
?>

如您所见,“index.php”上的 href url 没有用,因为它们被 javascript 中的“e.preventDefault();”停用。

完成所有工作的是“$('#link1').click(function(e) {..})”。

由于#content 是通过使用“$('#content').html(data.responseText);”动态传递的,我相信存在一个 DOM 问题,导致该网站无法被谷歌机器人抓取。

我阅读了这个谷歌帮助页面,它描述了如何使 ajax 驱动的网站对谷歌友好:

https://developers.google.com/webmasters/ajax-crawling/docs/getting-started

问题是他们似乎解释了如何使 url 使用 google 机器人可抓取的哈希值,但我的网站没有在链接中使用哈希值,所以我真的不知道应该做些什么来让我的网站被谷歌索引。

任何帮助,将不胜感激。

4

1 回答 1

3

你有两个选择:

  1. 重做您的网站以使用Google Crawlable Ajax Standard。但这是个坏主意

  2. 在不需要 JavaScript 的情况下制作您的网站。这是一个好主意,因为它使搜索引擎和人类都可以访问您的网站。请记住,并不是每个人都启用了 JavaScript。这称为渐进增强

于 2013-03-21T17:20:58.247 回答