在meteor中使用Spiderable重复显示头部内容,然后在body标签中显示html

时间:2015-08-13 17:31:47

标签: javascript ajax meteor phantomjs

我一直试图找出我在流星网站上遇到的这个奇怪的问题。我首先认为谷歌没有索引这是一个问题,但进一步调查到我认为我可能会在Spiderable包中引起某种问题。

我正在使用meteor版本1.1.0.3。根据{{​​3}}的建议,安装了spiderable包以及gadicohen:phantomjs。

我遇到的问题是,在结束新的head标签并显示正文和html内容之前,似乎没有为Google创建一个漂亮的html页面,而是在新的head标签中多次复制默认的head代码。代码很长,因此您可以访问meteorpedia并查看页面来源来查看问题。

我希望有人可能有想法或建议我可以做些什么来阻止重复并正确创建一个html版本供谷歌抓取。

修改

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

<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>

1 个答案:

答案 0 :(得分:0)

如果您使用铁路由器,则需要从html主模板(main || masterLayout || layout)中删除body标记和head标记,只留下{{> yield}}

示例:

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