【问题标题】:What is the significance of these two metadata elements in <head><head> 中这两个元数据元素有什么意义
【发布时间】:2019-03-11 11:40:04
【问题描述】:

我的&lt;head&gt; 中有一些多余的元数据标签,我不确定是否需要,也不知道它们的顺序是否正确。我正在使用宝石“元标签”

<%= csrf_meta_tags %>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<%= display_meta_tags %>

我是否需要两个 meta_tags 元素以及它们所在的位置好吗/最佳实践?

【问题讨论】:

  • 我猜你指的是csrf_meta_tagsdisplay_meta_tags。它们完全不同:csrf_meta_tags 是用于处理请求伪造的 Rails 助手,display_meta_tags 是用于显示 SEO 标签的元标记 gem 助手。位置对两者都很好(head 中元标记的顺序并不重要)
  • @AbM 谢谢,这很有趣。我从来不知道他们完全不同!我应该删除这个问题,还是要留下官方答案?
  • @AbM 快速说明 - charset 元标记应该是头中的第一个元标记 - 至少对于那个标记来说,顺序确实很重要。 stackoverflow.com/questions/30682496/…
  • 感谢@MaximillianLaumeister,我在下面的答案中添加了您的评论

标签: html ruby-on-rails


【解决方案1】:

我猜你指的是csrf_meta_tagsdisplay_meta_tags。它们完全不同:

位置对两者都很好。 head 中元标记的顺序并不重要,除了 charset 元标记 should be in the first position

【讨论】:

    猜你喜欢
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-22
    相关资源
    最近更新 更多