为每个URL(而非页面)打开图元标记 [英] Open Graph Metatags for every URL instead of page

查看:129
本文介绍了为每个URL(而非页面)打开图元标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个类似于facebook wall的页面,该页面具有Angular(SPA)中的帖子列表.每个帖子都有唯一的URL,可以准确地到达该帖子.我是新来的开放图元标记.我已经在head标签中插入了metatag.

I have developed a page similar to facebook wall which have list of post in Angular (SPA). Every post have unique url to reach exactly to that post. I am new to open graph metatags. I have inserted metatags in head tag.

 <meta property="og:url" content="#####"/>
    <meta property="og:type" content="website"/>
    <meta property="og:title" content="####"/>
    <meta property="og:description"
          content="######"/>
    <meta property="og:image" content="/images/####.png"/>

元标记对于每个帖子都是通用的,如何为每个url(帖子)分配元标记?

提前谢谢!

推荐答案

我已经按照

  • 我构建了一个非公共的,最小的jsp页面,其中包含所有必要的og标签. OG标签是在查询数据库之后生成的,因此它们是动态的.

    1. I built a non-public, minimal jsp page with all og tags necessary. OG Tags were generated after query database, so they are dynamic.

            <!doctype html>
                <html lang="en">
    
    
                    <head>
                        <sql:query dataSource="jdbc/localMysql" var="result">
                            ---- Query -------
                        </sql:query>
                        <c:forEach var="row" items="${result.rows}">
                            <meta property="og:type" content="website" />
                            <meta name= "twitter:card" content="summary" />
                            <meta name= "twitter:site" content="@#####" />
                            <meta property="og:title" content='<c:out value=" ${row.######} "/>' />
                            <meta name="og:description" content='<c:out value=" ${Jsoup.parse(row.######).text()} "/>' />
                            <meta name="twitter:card" content='<c:out value=" ${Jsoup.parse(row.######).text()} "/>' />
                            <c:if test="${not empty row.#####}">
                                <meta property="og:image" content='/UserImages/<c:out value=" ${fn:trim(row.####)} "/>' />
                                <meta name= "twitter:card" content="summary_large_image" />
                            </c:if>
                        </c:forEach>
                    </head>
    
                    <body>
    
                    </body>
    
                </html>
    

  • 我已经使用tuckey urlrewrite构建了爬虫检测模块,如果其用户显示的是正常页面,而显示其爬虫的是非公共jsp页面,则为

  • I have built a crawler detection module using tuckey urlrewrite, if its user I show normal page while if its crawler a non public jsp page is shown.

    <rule>
        <condition name="user-agent" next="or">facebookexternalhit/*
    </condition>
        <condition name="user-agent" next="or">Facebot</condition>
        <condition name="user-agent">Twitterbot/*</condition>
        <from>/wall/*</from>
        <set name="postUrl">$1</set>
        <to>/crawler-index.jsp</to>
    </rule>
    <rule>
        <from>/wall/*</from>
        <to>/index.jsp</to>
    </rule>
    

  • 这篇关于为每个URL(而非页面)打开图元标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆