2015-08-28 48 views
-1

我在我的网站上有几个HTML页面,在顶部显示相同的菜单。如果我需要更正,我需要编辑并上传所有这些HTML页面。我创建了一个可以回显菜单的php文件。当页面加载时,我通过Ajax在<body>处调用这个php文件。这工作正常。问题是,由于当谷歌或其他索引机器人抓取我的页面时,HTML文件中不存在菜单,它会以任何方式影响页面排名吗?会调用php函数调用的页面菜单是否会影响谷歌索引?

+0

我不知道索引,但我相信你应该通过菜单,边栏等来获得索引文件,并通过AJAX将内容加载到它,或者将HTML页面更改为PHP,并在其中包含标题。如果您仍然使用当前的解决方案,则无需在PHP文件中回显菜单。您可以通过AJAX加载HTML文件。 –

回答

0

为了使这种无缝的前端,你应该在服务器上使用PHP,包括()做这不是在前端

更好的方式来做到这一点的JavaScript,如果您的大多数页面是相同的,你可以做这个页脚和菜单以及,这意味着你只需要在每个文件的页面上有什么

我在这种情况下做的是创建页面我想要的方式然后将其分成三部分(如果菜单不是直接位于标签后,则为四个部分)

这使得它非常容易泰恩后,其他明智的您将有不同的代码在每一页上

例如头文件(在这个例子中,你会调用它的header.php)

<?php 
// header 
?> 


<!doctype html> 

<html lang="en"> 
<head> 
    <meta charset="utf-8"> 

    <title>The HTML5 Herald</title> 
    <meta name="description" content="The HTML5 Herald"> 
    <meta name="author" content="SitePoint"> 

    <link rel="stylesheet" href="css/styles.css?v=1.0"> 

    <!-- any other style sheets you want to link too go here --> 

    <!--[if lt IE 9]> 
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 
    <![endif]--> 
</head> 

<body> 

<?php 

// if your header is the top of the page put it here 



// end of file 

示例页面这是你调用(如索引页面.PHP将是你的第一个,然后他们的名字,你希望他们

<?php 
// basic page template 

//Header goes here 
include('header.php'); 
// if your header is horizontal and semantically at the top of the page you include your menu in the header.php file 

// if your menu is not sematically at the top you can add it in where ever you wish, bottom right left etc 
include('menu.php'); 

?> 

<!--   Some page content    --> 
<!--   Some page content    --> 
<!--   Some page content    --> 
<!--   Some page content    --> 

<?php 

//include your footer 
include('footer.php'); 

// end of file 

例页脚文件(在这个例子中,你会称它为footer.php)

<?php 
// footer file 
?> 
    <script src="js/scripts.js"></script> 

<!-- put your javascript in the footer --> 
</body> 
</html> 

<?php 

// end of file 
+0

谢谢jDoGG,但是这会让我重新命名从.htm到.php的所有页面的扩展名,这是我不想要的。 – sridhar

+0

@sridhar为什么你关心更改页面名称?如果因为搜索引擎的原因,您可以使用.htaccess轻松解决该问题,无论是mod重写还是301重定向 – JDoGG

相关问题