Skip to content

Commit 7524227

Browse files
committed
Set up meta-tags install and use for article layout
1 parent fe4d589 commit 7524227

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

app/content/layouts/article.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<%= set_meta_tags(
2+
title: current_page.data.title!,
3+
description: current_page.data.description,
4+
keywords: "Rails, Hotwire"
5+
) %>
16
<%= render "application/skip_to_content" %>
27
<%= render_layout "application" do %>
38
<article itemscope itemtype="http://schema.org/Article">

app/views/layouts/application.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html class="motion-safe:scroll-smooth">
33
<head>
4-
<title>Joy of Rails</title>
4+
<%= display_meta_tags site: "Joy of Rails" %>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
66
<meta name="apple-mobile-web-app-capable" content="yes">
77
<%= render "application/google_fonts" %>
@@ -22,7 +22,6 @@
2222
<%= vite_javascript_tag "application.js", media: "all", "data-turbo-track": "reload" %>
2323

2424
<%= auto_discovery_link_tag(:rss, feed_index_url, {title: "joyofrails.com"}) %>
25-
2625
<script type="text/javascript" defer data-domain="joyofrails.com" src="https://plausible.io/js/script.tagged-events.outbound-links.js"></script>
2726
<script type="text/javascript">window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }</script>
2827
<%= yield :head %>

config/initializers/meta_tags.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# frozen_string_literal: true
2+
3+
# Use this setup block to configure all options available in MetaTags.
4+
MetaTags.configure do |config|
5+
# How many characters should the title meta tag have at most. Default is 70.
6+
# Set to nil or 0 to remove limits.
7+
# config.title_limit = 70
8+
9+
# When true, site title will be truncated instead of title. Default is false.
10+
# config.truncate_site_title_first = false
11+
12+
# Add HTML attributes to the <title> HTML tag. Default is {}.
13+
# config.title_tag_attributes = {}
14+
15+
# Natural separator when truncating. Default is " " (space character).
16+
# Set to nil to disable natural separator.
17+
# This also allows you to use a whitespace regular expression (/\s/) or
18+
# a Unicode space (/\p{Space}/).
19+
# config.truncate_on_natural_separator = " "
20+
21+
# Maximum length of the page description. Default is 300.
22+
# Set to nil or 0 to remove limits.
23+
# config.description_limit = 300
24+
25+
# Maximum length of the keywords meta tag. Default is 255.
26+
# config.keywords_limit = 255
27+
28+
# Default separator for keywords meta tag (used when an Array passed with
29+
# the list of keywords). Default is ", ".
30+
# config.keywords_separator = ', '
31+
32+
# When true, keywords will be converted to lowercase, otherwise they will
33+
# appear on the page as is. Default is true.
34+
# config.keywords_lowercase = true
35+
36+
# When true, the output will not include new line characters between meta tags.
37+
# Default is false.
38+
# config.minify_output = false
39+
40+
# When false, generated meta tags will be self-closing (<meta ... />) instead
41+
# of open (`<meta ...>`). Default is true.
42+
# config.open_meta_tags = true
43+
44+
# List of additional meta tags that should use "property" attribute instead
45+
# of "name" attribute in <meta> tags.
46+
# config.property_tags.push(
47+
# 'x-hearthstone:deck',
48+
# )
49+
end

0 commit comments

Comments
 (0)