• meta理解及使用


    本文已参与「新人创作礼」活动,一起开启掘金创作之路

    meta

    meta 元素往往不会引起用户的注意,但是meta对整个网页有影响,
    会对网页能否被搜索引擎检索,和在搜索中的排名起着关键性的作用。
    
      meta有个必须的属性content用于表示需要设置的项的值。
    
      meta存在两个非必须的属性http-equiv和name, 用于表示要设置的项。
    
      比如
      
      
      设置的项是Content-Security-Policy设置的值是upgrade-insecure-requests。
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    理解

    name属性主要用于描述网页,
    与对应的content中的内容主要是便于搜索引擎查找信息和分类信息用的,
    用法与http-equiv相同,name设置属性名,content设置属性值。

    1. author
      author用来标注网页的作者
    "author" content="aaa@mail.abc.com">
    
    • 1
    1. description
      description用来告诉搜素引擎当前网页的主要内容,
      是关于网站的一段描述信息。
    	"description" content="这是我的HTML">
    
    • 1
    1. keywords
      keywords设置网页的关键字,来告诉浏览器关键字是什么。
      是一个经常被用到的名称。它为文档定义了一组关键字。
      某些搜索引擎在遇到这些关键字时,会用这些关键字对文档进行分类。
    "keywords" content="Hello world">
    
    • 1

    使用案例

    利于搜索引擎的搜索SEO
    和网站分享的内容设置
    
           
       const TKD = (props) => {
         const {
           title = "",
           keywords = "",
           description = "",
           share = {},
         } = props;
    
         const {
           img: shareImg = "",
           title: shareTitle = "",
           content: shareContent = "",
           callBack: shareCallBack = "",
         } = share;
    
         return (
           
             {title && <span class="token punctuation">{<!-- --></span>title<span class="token punctuation">}</span><<span class="token operator">/</span>title><span class="token punctuation">}</span>
             <span class="token punctuation">{<!-- --></span>keywords && <span class="token punctuation">(</span>
               <meta
                 name=<span class="token string">"keywords"</span>
                 content=<span class="token punctuation">{<!-- --></span>keywords<span class="token punctuation">.</span>replace<span class="token punctuation">(</span><span class="token operator">/</span><span class="token punctuation">[</span>,、<span class="token punctuation">]</span><span class="token operator">/</span>g<span class="token punctuation">,</span> <span class="token string">","</span><span class="token punctuation">)</span><span class="token punctuation">}</span>
               <span class="token operator">/</span>>
             <span class="token punctuation">)</span><span class="token punctuation">}</span>
             <span class="token punctuation">{<!-- --></span>description && <meta name=<span class="token string">"description"</span> 
             content=<span class="token punctuation">{<!-- --></span>description<span class="token punctuation">}</span> <span class="token operator">/</span>><span class="token punctuation">}</span>
             <meta
               name=<span class="token string">"sharecontent"</span>
               <span class="token keyword">data</span><span class="token operator">-</span>msg-img=<span class="token punctuation">{<!-- --></span>shareImg<span class="token punctuation">}</span>
               <span class="token keyword">data</span><span class="token operator">-</span>msg-title=<span class="token punctuation">{<!-- --></span>shareTitle<span class="token punctuation">}</span>
               <span class="token keyword">data</span><span class="token operator">-</span>msg-content=<span class="token punctuation">{<!-- --></span>shareContent<span class="token punctuation">}</span>
               <span class="token keyword">data</span><span class="token operator">-</span>msg-callback=<span class="token punctuation">{<!-- --></span>shareCallBack<span class="token punctuation">}</span>
               <span class="token keyword">data</span><span class="token operator">-</span>line-img=<span class="token punctuation">{<!-- --></span>shareImg<span class="token punctuation">}</span>
               <span class="token keyword">data</span><span class="token operator">-</span>line-title=<span class="token punctuation">{<!-- --></span>shareTitle<span class="token punctuation">}</span>
               <span class="token keyword">data</span><span class="token operator">-</span>line-callback=<span class="token punctuation">{<!-- --></span>shareCallBack<span class="token punctuation">}</span>
             <span class="token operator">/</span>>
           <<span class="token operator">/</span>Helmet>
         <span class="token punctuation">)</span><span class="token punctuation">;</span>
       <span class="token punctuation">}</span><span class="token punctuation">;</span>
    <div class="hljs-button signin" data-title="登录后复制" data-report-click="{"spm":"1001.2101.3001.4334"}"></div></code><div class="hide-preCode-box"><span class="hide-preCode-bt" data-report-view="{"spm":"1001.2101.3001.7365"}"><img class="look-more-preCode contentImg-no-view" src="https://1000bd.com/contentImg/2022/06/27/191644837.png" alt="" title=""></span></div><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li><li style="color: rgb(153, 153, 153);">14</li><li style="color: rgb(153, 153, 153);">15</li><li style="color: rgb(153, 153, 153);">16</li><li style="color: rgb(153, 153, 153);">17</li><li style="color: rgb(153, 153, 153);">18</li><li style="color: rgb(153, 153, 153);">19</li><li style="color: rgb(153, 153, 153);">20</li><li style="color: rgb(153, 153, 153);">21</li><li style="color: rgb(153, 153, 153);">22</li><li style="color: rgb(153, 153, 153);">23</li><li style="color: rgb(153, 153, 153);">24</li><li style="color: rgb(153, 153, 153);">25</li><li style="color: rgb(153, 153, 153);">26</li><li style="color: rgb(153, 153, 153);">27</li><li style="color: rgb(153, 153, 153);">28</li><li style="color: rgb(153, 153, 153);">29</li><li style="color: rgb(153, 153, 153);">30</li><li style="color: rgb(153, 153, 153);">31</li><li style="color: rgb(153, 153, 153);">32</li><li style="color: rgb(153, 153, 153);">33</li><li style="color: rgb(153, 153, 153);">34</li><li style="color: rgb(153, 153, 153);">35</li><li style="color: rgb(153, 153, 153);">36</li><li style="color: rgb(153, 153, 153);">37</li><li style="color: rgb(153, 153, 153);">38</li><li style="color: rgb(153, 153, 153);">39</li><li style="color: rgb(153, 153, 153);">40</li><li style="color: rgb(153, 153, 153);">41</li><li style="color: rgb(153, 153, 153);">42</li><li style="color: rgb(153, 153, 153);">43</li></ul></pre>
                    </div>
                        </div>
                    </li>
    
                    <li class="list-group-item ul-li">
    
                        <b>相关阅读:</b><br>
                        <nobr>
    <a href="/Article/Index/1463261">ffmpeg和ffplay</a>                            <br />
    <a href="/Article/Index/1289140">DETR纯代码分享(五)__init__.py(datasets)</a>                            <br />
    <a href="/Article/Index/922329">selenium-语法</a>                            <br />
    <a href="/Article/Index/1339434">客厅、厨房、卫生间瓷砖怎么挑选,看完不再烦恼!福州中宅装饰,福州装修</a>                            <br />
    <a href="/Article/Index/1339764">【Unity】两种方式实现弹跳平台/反弹玩家(玩家触发与物体自身触发事件实现蹦床的物理效果)</a>                            <br />
    <a href="/Article/Index/1104575">计算机网络面试题</a>                            <br />
    <a href="/Article/Index/1251330">【嵌入式数据库之sqlite3】</a>                            <br />
    <a href="/Article/Index/869245">手把手教你搭建zookeeper和kafka集群(超级详细)</a>                            <br />
    <a href="/Article/Index/873509">一文梳理SpringCloud常见知识点</a>                            <br />
    <a href="/Article/Index/805170">Verilog:【6】PWM调制器(pwm_modulator.sv)</a>                            <br />
                        </nobr>
                    </li>
                    <li class="list-group-item from-a mb-2">
                        原文地址:https://blog.csdn.net/qq_36262295/article/details/126689364
                    </li>
    
                </ul>
            </div>
    
            <div class="col-lg-4 col-sm-12">
                <ul class="list-group" style="word-break:break-all;">
                    <li class="list-group-item ul-li-bg" aria-current="true">
                        最新文章
                    </li>
                    <li class="list-group-item ul-li">
                        <nobr>
    <a href="/Article/Index/1484446">攻防演习之三天拿下官网站群</a>                            <br />
    <a href="/Article/Index/1515268">数据安全治理学习——前期安全规划和安全管理体系建设</a>                            <br />
    <a href="/Article/Index/1759065">企业安全 | 企业内一次钓鱼演练准备过程</a>                            <br />
    <a href="/Article/Index/1485036">内网渗透测试 | Kerberos协议及其部分攻击手法</a>                            <br />
    <a href="/Article/Index/1877332">0day的产生 | 不懂代码的"代码审计"</a>                            <br />
    <a href="/Article/Index/1887576">安装scrcpy-client模块av模块异常,环境问题解决方案</a>                            <br />
    <a href="/Article/Index/1887578">leetcode hot100【LeetCode 279. 完全平方数】java实现</a>                            <br />
    <a href="/Article/Index/1887512">OpenWrt下安装Mosquitto</a>                            <br />
    <a href="/Article/Index/1887520">AnatoMask论文汇总</a>                            <br />
    <a href="/Article/Index/1887496">【AI日记】24.11.01 LangChain、openai api和github copilot</a>                            <br />
                        </nobr>
                    </li>
                </ul>
    
                <ul class="list-group pt-2" style="word-break:break-all;">
                    <li class="list-group-item ul-li-bg" aria-current="true">
                        热门文章
                    </li>
                    <li class="list-group-item ul-li">
                        <nobr>
    <a href="/Article/Index/888177">十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!</a>                            <br />
    <a href="/Article/Index/797680">奉劝各位学弟学妹们,该打造你的技术影响力了!</a>                            <br />
    <a href="/Article/Index/888183">五年了,我在 CSDN 的两个一百万。</a>                            <br />
    <a href="/Article/Index/888179">Java俄罗斯方块,老程序员花了一个周末,连接中学年代!</a>                            <br />
    <a href="/Article/Index/797730">面试官都震惊,你这网络基础可以啊!</a>                            <br />
    <a href="/Article/Index/797725">你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法</a>                            <br />
    <a href="/Article/Index/797702">心情不好的时候,用 Python 画棵樱花树送给自己吧</a>                            <br />
    <a href="/Article/Index/797709">通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!</a>                            <br />
    <a href="/Article/Index/797716">13 万字 C 语言从入门到精通保姆级教程2021 年版</a>                            <br />
    <a href="/Article/Index/888192">10行代码集2000张美女图,Python爬虫120例,再上征途</a>                            <br />
                        </nobr>
                    </li>
                </ul>
    
            </div>
        </div>
    </div>
    <!-- 主体 -->
    
    
        <!--body结束-->
        <!--这里是footer模板-->
        
        <!--footer-->
    <nav class="navbar navbar-inverse navbar-fixed-bottom">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="text-muted center foot-height">
                        Copyright © 2022 侵权请联系<a href="mailto:2656653265@qq.com">2656653265@qq.com</a>   
                        <a href="https://beian.miit.gov.cn/" target="_blank">京ICP备2022015340号-1</a>
                    </div>
                    <div style="width:300px;margin:0 auto; padding:0px 5px;">
                        <a href="/regex.html">正则表达式工具</a>
                        <a href="/cron.html">cron表达式工具</a>
                        <a href="/pwdcreator.html">密码生成工具</a>
                    </div>
                    <div style="width:300px;margin:0 auto; padding:5px 0;">
                        <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11010502049817" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
                        <img src="" style="float:left;" /><p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">京公网安备 11010502049817号</p></a>
                    </div>
                </div>
            </div>
        </div>
      
    </nav>
    <!--footer-->
    
        <!--footer模板结束-->
    
        <script src="/js/plugins/jquery/jquery.js"></script>
        <script src="/js/bootstrap.min.js"></script>
    
        <!--这里是scripts模板-->
        
    
        
     
    
    
        <!--scripts模板结束-->
    
    </body>
    </html>