对< head>的建议流星的标签 [英] Suggestions for <head> tags for Meteor

查看:81
本文介绍了对< head>的建议流星的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我搜索教程和示例应用程序的过程中,我发现了一个使用独特头结构的类:

 < meta charset =utf-8> 
< title>标题< / title>
< meta name =descriptioncontent =Top10>
< meta name =viewportcontent =width = device-width/>
< meta name =viewportcontent =user-scalable = no,initial-scale = 1,maximum-scale = 1,minimum-scale = 1>

这个特殊的示例应用程序甚至没有< body> 标签,只是一个名为 head.html 的文件,其中包含上述代码。我也了解到,Meteor似乎只是自动为你制作一个body标签,所以在技术上,只是一个head.html很好。所以,它让我想知道,有没有人为Meteor应用程序定义特定的头标签?基本原理是什么?上面的代码是一个很好的起点吗?

解决方案

您可以使用iron:router轻松设置动态标题,例如:

  onAfterAction:function(){
document.title ='my awesome site:'+ Router.current()。route.getName();
}

我使用包含各种SEO设置的head.html:

 < head> 
< meta name =viewportcontent =width = device-width,initial-scale = 1/>
< meta name =fragmentcontent =!/>
< meta name =descriptioncontent =your description/>
< meta property =og:titlecontent =您的网站标题/>
< meta property =og:typecontent =website/>
< meta property =og:imagecontent =https:// yourimageurl/>
< meta property =og:urlcontent =https:// hostname/>
< meta property =og:descriptioncontent =your description/>
< meta name =twitter:cardcontent =summary/>
< meta name =twitter:urlcontent =https:// hostname/>
< meta name =twitter:titlecontent =您的网站标题/>
< meta name =twitter:descriptioncontent =您的网站描述/>
< meta name =twitter:imagecontent =https:// yourimageurl>
< noscript>您必须启用Javascript才能使用此网站< / noscript>
< link rel =快捷方式图标href =/ your-icotype =image / x-icon/>
< / head>


Fellow Meteor users,

During my searches for tutorials and example applications, I found one that uses a unique head structure:

  <meta charset="utf-8">
  <title>Title</title>
  <meta name="description" content="Top10">
  <meta name="viewport" content="width=device-width" />
  <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1">

This particular example app didn't even have a <body> tag anywhere, just a file called head.html which contained the above code. I also learned that it seems that Meteor just automatically makes a body tag for you, so technically, just a head.html is fine.

So, it got me wondering, does anyone define specific head tags for Meteor apps? What's the rationale? Is the above code a good starting point?

解决方案

You can easily set dynamic titles using iron:router for example with:

onAfterAction: function(){
  document.title = 'my awesome site: ' + Router.current().route.getName();
}

I use a head.html that includes various SEO settings:

<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="fragment" content="!"/>
<meta name="description" content="your description"/>
<meta property="og:title" content="your site title"/>
<meta property="og:type" content="website"/>
<meta property="og:image" content="https://yourimageurl"/>
<meta property="og:url" content="https://hostname"/>
<meta property="og:description" content="your description"/>
<meta name="twitter:card" content="summary"/>
<meta name="twitter:url" content="https://hostname"/>
<meta name="twitter:title" content="your site title"/>
<meta name="twitter:description" content="your site description"/>
<meta name="twitter:image" content="https://yourimageurl">
<noscript>You must have Javascript enabled in order to use this site</noscript>
<link rel="shortcut icon" href="/your-ico" type="image/x-icon" />
</head>

这篇关于对&lt; head&gt;的建议流星的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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