【问题标题】:How to include an html page in another page and have its contents be crawlable如何在另一个页面中包含一个 html 页面并使其内容可抓取
【发布时间】:2017-07-12 15:29:02
【问题描述】:

我需要在另一个 html 页面中包含一个 html 页面,并且我希望包含的页面 (page2.html) 的内容能够被 google 索引。我知道 iframe 不是解决方案,但搜索引擎如何处理 html 对象:

document.getElementById("content").innerHTML = '<object type="text/html" data="page2.html"></object>';

vs jQuery:

$(function(){$("#content").load("page2.html"); });
// <script type="text/javascript" src="../common_files/js/jquery-2.1.3.min.js"></script>  <-- in header

对于 html:

<div id="content"></div>

?还是有其他更好的解决方案?提前致谢。

【问题讨论】:

  • 在后端代码中做
  • 或者在服务器上使用SSI

标签: javascript jquery html seo


【解决方案1】:

如果您使用 javascript/jquery,无法 100% 保证内容会被 google 抓取。

您需要在服务器端执行此操作。 在 PHP 中,您可以使用 file_get_contents 函数来获取 page2.html

$homepage = file_get_contents('http://www.example.com/page2.html');

并将 $homepage 变量放入第一页。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 2018-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多