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

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

问题描述

Meteor 用户,

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

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

这个特定的示例应用程序甚至在任何地方都没有 标签,只有一个名为 head.html 的文件,其中包含上述代码.我还了解到 Meteor 似乎只是自动为你制作了一个 body 标签,所以从技术上讲,一个 head.html 就可以了.

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.

所以,我想知道,有没有人为 Meteor 应用定义特定的头部标签?理由是什么?上面的代码是一个很好的起点吗?

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?

推荐答案

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

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

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

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

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天全站免登陆