zoukankan      html  css  js  c++  java
  • Angular SEO方案

    1、如果是java web项目,可以直接使用AngularSEO Filter。

                   官网地址 :http://www.angularseo.net/#about

    <filter>
    	<filter-name>SEOFilter</filter-name>
    	<display-name>SEOFilter</display-name>
    	<description>AngularSEO Filter</description>
    	<filter-class>net.angularseo.SEOFilter</filter-class>
    	<!-- The path to the PhantomJS binary -->
    	<init-param>
    		<param-name>phantomjs.binary.path</param-name>
    		<param-value>C:\phantomjs2.0\bin\phantomjs.exe</param-value>
    	</init-param>
    	<!-- The time waiting the JS page to finish the dynamic loading, unit is second.
    	 -->
    	<init-param>
    		<param-name>waitForPageLoad</param-name>
    		<param-value>3</param-value>
    	</init-param>
    	<!-- Filter already embed google, bing, baidu UserAgent keywords,
    	     If you want to support more, add them and split with |
    	 -->
    	<init-param>
    		<param-name>robotUserAgents</param-name>
    		<param-value>YodaoBot|Zealbot</param-value>
    	</init-param>
    	<!-- The interval that SEOFilter update the static page snapshot -->
    	<init-param>
    		<param-name>cacheTimeout</param-name>
    		<param-value>24</param-value>
    	</init-param>	
    	<!-- The path to save the static version pages -->
    	<init-param>
    		<param-name>cachePath</param-name>
    		<param-value>c:\cache</param-value>
    	</init-param>
    	<!-- crawlDepth is used to limited the crawl depth -->
    	<init-param>
    		<param-name>crawlDepth</param-name>
    		<param-value>10</param-value>
    	</init-param>
    	<!-- The default page encoding of this site -->
    	<init-param>
    		<param-name>encoding</param-name>
    		<param-value>UTF-8</param-value>
    	</init-param>		
    </filter>
    <filter-mapping>
    	<filter-name>SEOFilter</filter-name>
    	<url-pattern>/*</url-pattern>
    </filter-mapping>
                         
    

      

    关于phantomjs: http://phantomjs.org/

    2、后台针对每一个需要SEO的页面分别写一套,在后台渲染生成html的代码,嵌入到前台的html中,但是不显示。

    <div style="display:none">
            ///后台生成的专门为了SEO需要的代码
            //在后台可以通过判断请求的agent参数,判断是否是搜索引擎爬虫,如果不是,不需要生成这段隐藏的代码。
    </div>
    
    <div ng-app="XXApp" ng-controller="XXController">
           //前台业务的代码
    </div>
    

      

     

  • 相关阅读:
    C#获取当前路径
    惠普辞退4000员工,今后如何走
    提升你的编码技能,你不知道的免费在线编码资源(上)
    iPhone 5在美销量有望破5000万,Facebook手机何去何从?
    Python获取命令行参数
    C#递归获取文件目录
    Pixel’d:共创美好的像素艺术
    PayPal走向现实支付,消费者们会来买帐吗?
    兼容性测试、手工测试、自动化测试及探索性测试
    冒烟测试 smoking test
  • 原文地址:https://www.cnblogs.com/lhp2012/p/5229954.html
Copyright © 2011-2022 走看看