gpt4 book ai didi

javascript - 在meteor中使用Spiderable会在body标签中显示html之前复制head内容

转载 作者:行者123 更新时间:2023-11-28 07:02:32 27 4
gpt4 key购买 nike

我一直在试图解决我的 meteor 网站遇到的这个奇怪的问题。我首先认为这是 Google 未建立索引的问题,但经过进一步调查,我认为我可能会导致 Spiderable 包出现某种问题。

我使用的是 meteor 版本1.1.0.3。按照meteorpedia的建议安装了spiderable包以及gadicohen:phantomjs 。

我遇到的问题是,它似乎没有为 Google 创建一个漂亮的 html 页面,而是在新的 head 标签内多次重复默认的 head 代码,然后结束新的 head 标签并显示正文和 html 内容。代码比较长,可以通过访问suleimanholdings.com?_escaped_fragment_=查看问题。并查看页面源代码。

我希望有人对我可以采取什么措施来停止重复并正确创建一个 html 版本供 Google 抓取有一个想法或建议。

编辑

以下是我使用的代码,每个模板都在正文标记之间输入

<head>
<meta charset="UTF-8">
<title>Suleiman Holdings</title>
<link rel="icon" href="/favicon.ico?v=2">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="screen" />
<script src="/prefixfree.min.js"></script>
<script src="/jquery.flexslider.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-62610011-1', 'auto');
ga('send', 'pageview');

</script>

编辑2

This is the template code from the homepage:

<template name="home">
{{> nav}}


<div style="overflow:hidden">
<div id="main" role="main">
<section class="slider">
<div class="flexslider">
<ul class="slides">
<div class="slider-bottom"></div>
<li style="background-image: url('/one-tech2.jpg');">
<div class="news" style="background-image : linear-gradient(to bottom, rgba(255,255,255, 0), rgba(255,255,255, .6) 20%);">
<h1>
One Technology Place
</h1>
<div class="news2">
<h2>
Acquired: February 2015
</h2>
<p>
Suleiman Holdings acquires the Nebraska Technology Park’s flagship office in a 3.3M cash transaction.
</p>
</div>
</div>
<div class="slider-bottom">
<div class="line" style="margin-left:0px; margin-right:10px;"></div>
<h3>
2015
</h3>
<div class="line" style="margin-left:80px"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
</li>
<li style="background-image: url('/12thQ-inside2.jpg');">
<div class="news" style="background-image : linear-gradient(to bottom, rgba(255,255,255, 0), rgba(255,255,255, .6) 20%);">
<h1>
University of Nebraska
</h1>
<div class="news2">
<h2>
Leased: January 2015
</h2>
<p>
Suleiman Holdings welcomes the University of Nebraska College of Journalism and Mass Communications to Downtown Lincoln
</p>
</div>
</div>
<div class="slider-bottom">
<div class="line" style="margin-left:0px; margin-right:10px;"></div>
<h3>
2015
</h3>
<div class="line" style="margin-left:80px"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
</li>
<li style="background-image: url('/interns.jpg');">
<div class="news" style="background-image : linear-gradient(to bottom, rgba(255,255,255, 0), rgba(255,255,255, .7) 20%);">
<h1>
Summer Internship Series
</h1>
<div class="news2">
<h2>
Starting Summer 2015
</h2>
<p>
Suleiman Holdings welcomes three interns to Lincoln for a summer of acquisitions and accounting.
</p>
</div>
</div>
<div class="slider-bottom">
<div class="line" style="margin-left:0px; margin-right:10px;"></div>
<h3>
2015
</h3>
<div class="line" style="margin-left:80px"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
</li>
</ul>
</div>
</section>
</div>
</div>
{{> footer}}
</template>

这是导航模板的代码

<template name="nav">

<div class="logobox">
<div class="mainnavwrap">
<div class="menumain">
<a href="/">
<div style="position:absolute; height:50px; width:150px; top:0px; z-index:5500; margin-left:60px;"></div>
</a>
<ul style="/*position:absolute; width:400px; right:0;*/">

<!--<li><a href="private-equity">PRIVATE EQUITY</a></li>
<li><a href="real-estate">REAL ESTATE</a></li>-->
</ul>
</div>
</div>

<div class="toggleMobile">
<span class="menu1"></span>
<span class="menu2"></span>
<span class="menu3"></span>
</div>
<div class="logo2">
<a href="home"><img src="/logo-black.png"></a>
</div>
<div id="mobileMenu">
<ul>
<a href="home">
<li>HOME</li>
</a>

<a href="real-estate">
<li>REAL ESTATE</li>
</a>
<a href="private-equity">
<li>PRIVATE EQUITY</li>
</a>
<a href="about"><li>ABOUT</li></a>
</ul>
</div>
</div>
</template>

这是页脚模板的代码

<template name="footer">
<div class="footer">
<span class="copyright">&copy; Copyright 2015 Suleiman Holdings</span>

<div class="legal">
<span style="margin-left:20px; font-size:12px;">
<a href="about" style="margin-right:10px;">About</a>
<a href="press" style="margin-right:10px;">Press</a>
<!--<a href="careers" style="margin-right:10px;">Careers</a>-->
<label class="btn" for="modal-1">Contact</label>
<a href="legal">Legal</a>
</span>
</div>
</div>


<input class="modal-state" id="modal-1" type="checkbox"/>

<div class="modal">
<label class="modal__bg" for="modal-1"></label>

<div class="modal__inner">
<label class="modal__close" for="modal-1"></label>

<div class="contact">
<div class="con-logo"><img src="/contact-logo.jpg"></div>
<p>
4665 Innovation Drive
<br>
Lincoln, Nebraska 68521
</p>
</div>
</div>
</div>

</template>

最佳答案

如果您使用iron router,您需要从 html 主模板( main || )中删除 body 标签和 head 标签。 masterLayout ||布局)并只保留{{>yield}}

示例:

<template name="masterLayout">
{{> navbar}}
<div class="container">
{{> yield}}
</div>
</template>

关于javascript - 在meteor中使用Spiderable会在body标签中显示html之前复制head内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31994869/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com