meta-tags 2.22.3 → 2.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d14babad77499d7760b9227ee1c94901ab6926cf1c068c942bac1ab1d810567
4
- data.tar.gz: 4a2009413ba29de63675dd5429f9341bda138c977c63ca449edc244c54bf731b
3
+ metadata.gz: 8b4bb486b4a8b270f4e782ad51e97e5df1e48c494226f28c4242aaf17b4a20a3
4
+ data.tar.gz: 43ff472ad6406ee187d1234eb363d6a9a9d9360c460b651bfcf00ab503a62d01
5
5
  SHA512:
6
- metadata.gz: 04d053a661471fd3dec669571d11da00062b47a295a04c1a0d7f476e0c283fd258f1d751a2db00e684be7b0ab2b1b50a0496c2e1a796db1958303d408d6f20b8
7
- data.tar.gz: b04ad7ecbc6f8b45316eb98ab7fe99a0ad515b2c2c4acb9df01eb71cb86b09a6fd33722a5076e0a94260faeb95bbccd4cebe7e81756e05f99ad749a61029e462
6
+ metadata.gz: 98406f57fb0efc987f850478b5178c95634785853fdda24898aecde45b40893920c3533b86627d12e8a5b2cdd7526fb3a7c15b44617087c2029cb2329dac2908
7
+ data.tar.gz: dde7d53752a74f005e5ddafafea009c17aad3e67f119e825f5478285421c041060b7b766d7bcdb04bd4fb1bdea0d892a59b8a84e9c348ef55786b90b12c9a189
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 2.23.0 (March 16, 2026) [☰](https://github.com/kpumuk/meta-tags/compare/v2.22.3...v2.23.0)
6
+
7
+ Bugfixes:
8
+
9
+ - Fixed `title` helper to always return a string, joining array titles with the configured separator ([344](https://github.com/kpumuk/meta-tags/pull/344)).
10
+ - Fixed packaged RBS interfaces for Rails helpers so `_ActionViewBase` and `_ActionControllerBase` resolve for gem consumers ([345](https://github.com/kpumuk/meta-tags/pull/345)).
11
+
12
+ Changes:
13
+
14
+ - Refreshed README and generated docs to describe modern SEO guidance more accurately, while keeping legacy metadata features documented as compatibility options ([349](https://github.com/kpumuk/meta-tags/pull/349)).
15
+ - Optimized property tag matching to improve metadata rendering performance and reduce allocations and memory use on the hot render path ([350](https://github.com/kpumuk/meta-tags/pull/350)).
16
+
3
17
  ## 2.22.3 (January 7, 2026) [☰](https://github.com/kpumuk/meta-tags/compare/v2.22.2...v2.22.3)
4
18
 
5
19
  Changes:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # MetaTags: a gem to make your Rails application SEO-friendly
1
+ # MetaTags: Rails helpers for SEO metadata, sharing, canonical URLs, and robots
2
2
 
3
3
  [![Tests](https://github.com/kpumuk/meta-tags/actions/workflows/tests.yml/badge.svg)](https://github.com/kpumuk/meta-tags/actions/workflows/tests.yml)
4
4
  [![Gem Version](https://badge.fury.io/rb/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)
@@ -6,7 +6,9 @@
6
6
  [![Gem Downloads](https://img.shields.io/gem/dt/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)
7
7
  [![Changelog](https://img.shields.io/badge/Changelog-latest-blue.svg)](https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md)
8
8
 
9
- Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
9
+ MetaTags helps Ruby on Rails applications render HTML head metadata such as titles, descriptions, canonical links, robots directives, Open Graph tags, X card tags, and hreflang links.
10
+
11
+ It supports the metadata layer of search engine optimization (SEO), especially for titles, descriptions, canonicalization, robots directives, and social sharing previews.
10
12
 
11
13
  ## Ruby on Rails
12
14
 
@@ -15,6 +17,9 @@ The MetaTags main branch fully supports Ruby on Rails 6.1+ and is tested against
15
17
  > [!NOTE]
16
18
  > We no longer support Ruby versions older than 3.0 and Ruby on Rails older than 6.1 since they reached their end of life (see [Ruby](https://endoflife.date/ruby) and [Ruby on Rails](https://endoflife.date/rails)).
17
19
 
20
+ > [!IMPORTANT]
21
+ > MetaTags manages HTML head metadata. It does not generate structured data / JSON-LD, `robots.txt`, sitemaps, internal links, or page content.
22
+
18
23
  ## Installation
19
24
 
20
25
  Add the "meta-tags" gem to your `Gemfile`.
@@ -27,7 +32,7 @@ And run `bundle install` command.
27
32
 
28
33
  ## Configuration
29
34
 
30
- MetaTags follows best practices for meta tags. Although default limits for truncation have recommended values, you can change them to reflect your own preferences. Keywords are converted to lowercase by default, but this is also configurable.
35
+ MetaTags ships with practical defaults for truncation and rendering. You can change them to match your application. Legacy fields such as `keywords` are still supported for compatibility, but they are not modern search requirements.
31
36
 
32
37
  To override the defaults, create an initializer `config/initializers/meta_tags.rb` using the following command:
33
38
 
@@ -76,7 +81,6 @@ You can define the following instance variables:
76
81
  ```ruby
77
82
  @page_title = "Member Login"
78
83
  @page_description = "Member login page."
79
- @page_keywords = "Site, Login, Members"
80
84
  ```
81
85
 
82
86
  Also, you could use the `set_meta_tags` method to define all meta tags simultaneously:
@@ -84,8 +88,7 @@ Also, you could use the `set_meta_tags` method to define all meta tags simultane
84
88
  ```ruby
85
89
  set_meta_tags(
86
90
  title: "Member Login",
87
- description: "Member login page.",
88
- keywords: "Site, Login, Members"
91
+ description: "Member login page."
89
92
  )
90
93
  ```
91
94
 
@@ -98,7 +101,6 @@ To set meta tags, you can use the following methods:
98
101
  ```erb
99
102
  <% title "Member Login" %>
100
103
  <% description "Member login page." %>
101
- <% keywords "Site, Login, Members" %>
102
104
  <% nofollow %>
103
105
  <% noindex %>
104
106
  <% refresh 3 %>
@@ -110,8 +112,7 @@ Also, the `set_meta_tags` method exists:
110
112
  <%
111
113
  set_meta_tags(
112
114
  title: "Member Login",
113
- description: "Member login page.",
114
- keywords: "Site, Login, Members"
115
+ description: "Member login page."
115
116
  )
116
117
  %>
117
118
  ```
@@ -154,7 +155,7 @@ Use these options to customize the title format:
154
155
  | `:site` | Site title |
155
156
  | `:title` | Page title |
156
157
  | `:description` | Page description |
157
- | `:keywords` | Page keywords |
158
+ | `:keywords` | Legacy keywords meta tag for compatibility; ignored by Google Search and Bing web search |
158
159
  | `:charset` | Page character set |
159
160
  | `:prefix` | Text between site name and separator |
160
161
  | `:separator` | Text used to separate the website name from the page title |
@@ -167,9 +168,9 @@ Use these options to customize the title format:
167
168
  | `:follow` | Add follow meta tag; when true, "robots" will be used; accepts a string with a robot name or an array of strings |
168
169
  | `:noarchive` | Add noarchive meta tag; when true, "robots" will be used; accepts a string with a robot name or an array of strings |
169
170
  | `:canonical` | Add canonical link tag |
170
- | `:prev` | Add prev link tag |
171
- | `:next` | Add next link tag |
172
- | `:image_src` | Add image_src link tag |
171
+ | `:prev` | Add legacy prev pagination link tag |
172
+ | `:next` | Add legacy next pagination link tag |
173
+ | `:image_src` | Add legacy image_src share hint |
173
174
  | `:og` | Add Open Graph tags (Hash) |
174
175
  | `:twitter` | Add Twitter tags (Hash) |
175
176
  | `:refresh` | Refresh interval and optionally URL to redirect to |
@@ -196,7 +197,7 @@ set_meta_tags title: ["part1", "part2"], reverse: true, site: "site"
196
197
  # part2 | part1 | site
197
198
  ```
198
199
 
199
- Keywords can be passed as a string of comma-separated values or as an array:
200
+ If you still need the legacy `keywords` tag, values can be passed as a string of comma-separated values or as an array:
200
201
 
201
202
  ```ruby
202
203
  set_meta_tags keywords: ["tag1", "tag2"]
@@ -266,7 +267,6 @@ def default_meta_tags
266
267
  {
267
268
  title: "Member Login",
268
269
  description: "Member login page.",
269
- keywords: "Site, Login, Members",
270
270
  separator: "&mdash;".html_safe
271
271
  }
272
272
  end
@@ -289,11 +289,13 @@ And in your pjax templates:
289
289
  <% end %>
290
290
  ```
291
291
 
292
- ## SEO Basics and MetaTags
292
+ ## Search and Sharing Metadata
293
+
294
+ These tags still matter for search snippets, canonicalization, robots directives, and social sharing. They are only one part of modern SEO. You should combine them with good page content, internal links, structured data, sitemaps, and crawl controls where appropriate.
293
295
 
294
296
  ### Titles
295
297
 
296
- Page titles are very important for search engines. The titles in the browser are displayed in the title bar. Search engines look at the title bar to determine what the page is all about.
298
+ Page titles help browsers, social previews, and search engines understand the page. Use unique, descriptive titles that match the visible page content.
297
299
 
298
300
  ```ruby
299
301
  set_meta_tags title: "Member Login"
@@ -304,15 +306,16 @@ set_meta_tags site: "Site Title", title: "Member Login", reverse: true
304
306
  # <title>Member Login | Site Title</title>
305
307
  ```
306
308
 
307
- Recommended title tag length: up to **70 characters** in **10 words**.
309
+ Google does not publish a fixed title length. Keep titles concise and informative; search results may truncate them based on available width.
308
310
 
309
311
  Further reading:
310
312
 
311
313
  - [Title Tag](https://moz.com/learn/seo/title-tag)
314
+ - [Google Search Central: title links](https://developers.google.com/search/docs/appearance/title-link)
312
315
 
313
316
  ### Description
314
317
 
315
- Description meta tags are not displayed by browsers, unlike titles. However, some search engines may choose to display them. These tags are utilized to provide a concise summary of a webpage's content, typically within 2 or 3 sentences.
318
+ Description meta tags help search engines generate snippets, but search engines may also use visible page text instead. Write a short summary that matches the page.
316
319
 
317
320
  Below is an example of how to set a description tag using Ruby:
318
321
 
@@ -321,26 +324,29 @@ set_meta_tags description: "This is a sample description"
321
324
  # <meta name="description" content="This is a sample description">
322
325
  ```
323
326
 
324
- It is advisable to limit the length of the description tag to **300 characters**.
327
+ Google does not publish a fixed meta description length. Make the description long enough to be useful and specific, not long enough to hit an arbitrary character count.
325
328
 
326
329
  Further reading:
327
330
 
328
331
  - [Meta Description](https://moz.com/learn/seo/meta-description)
329
332
  - [How Long Should Your Meta Description Be? (2018 Edition)](https://moz.com/blog/how-long-should-your-meta-description-be-2018)
333
+ - [Google Search Central: control your snippets in search results](https://developers.google.com/search/docs/appearance/snippet)
330
334
 
331
335
  ### Keywords
332
336
 
333
- Meta keywords tags are used to place keywords that you believe users would search for in search engines. It is important to avoid unnecessary repetition of keywords, as this could be considered spam and may result in a permanent ban from search engine results pages (SERPs).
337
+ The `keywords` tag is a legacy feature. MetaTags still supports it for backwards compatibility and for systems that still read it, but it is not a modern web SEO signal.
334
338
 
335
339
  ```ruby
336
340
  set_meta_tags keywords: %w[keyword1 keyword2 keyword3]
337
341
  # <meta name="keywords" content="keyword1, keyword2, keyword3">
338
342
  ```
339
343
 
340
- It is recommended to keep the length of the keywords tag under **255 characters** or **20 words**.
341
-
342
344
  > [!NOTE]
343
- > Both Google and Bing have publicly stated that they completely ignore keywords meta tags.
345
+ > Google Search ignores the `keywords` meta tag, and Bing web search has long treated it the same way. Use this tag only if you have your own downstream consumer for it.
346
+
347
+ Further reading:
348
+
349
+ - [Google Search Central: meta tags Google supports](https://developers.google.com/search/docs/crawling-indexing/special-tags)
344
350
 
345
351
  ### Noindex
346
352
 
@@ -353,16 +359,17 @@ set_meta_tags noindex: "googlebot"
353
359
  # <meta name="googlebot" content="noindex">
354
360
  ```
355
361
 
356
- This is useful for pages like login, password reset, privacy policy, etc.
362
+ This is useful for pages like login, password reset, cart, account settings, or internal search results.
357
363
 
358
364
  Further reading:
359
365
 
360
366
  - [Blocking Google](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93708)
361
367
  - [Using meta tags to block access to your site](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=93710)
368
+ - [Google Search Central: robots meta tag and X-Robots-Tag](https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag)
362
369
 
363
370
  ### Index
364
371
 
365
- Although it is not required to add "index" to "robots" as it is the default value for Google, some SEO specialists recommend adding it to the website.
372
+ In most cases, you do not need to emit `index` explicitly because it is already the default for crawlable pages.
366
373
 
367
374
  ```ruby
368
375
  set_meta_tags index: true
@@ -384,10 +391,11 @@ Further reading:
384
391
 
385
392
  - [About rel="nofollow"](http://www.google.com/support/webmasters/bin/answer.py?answer=96569)
386
393
  - [Meta tags](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=79812)
394
+ - [Google Search Central: robots meta tag and X-Robots-Tag](https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag)
387
395
 
388
396
  ### Follow
389
397
 
390
- You can use the Noindex meta tag in conjunction with Follow.
398
+ You can use `follow` with `noindex` if you need that combination, but most pages do not need an explicit `follow` tag because it is also the default behavior.
391
399
 
392
400
  ```ruby
393
401
  set_meta_tags noindex: true, follow: true
@@ -398,10 +406,10 @@ This tag will prevent search engines from indexing this specific page, but it wi
398
406
 
399
407
  ### Canonical URL
400
408
 
401
- Canonical link elements tell search engines what the canonical or main URL is for content that has multiple URLs. The search engine will always return that URL, and link popularity and authority will be applied to that URL.
409
+ Canonical link elements help search engines consolidate duplicate or near-duplicate URLs under one preferred URL. They are a signal, not a guarantee.
402
410
 
403
411
  > [!NOTE]
404
- > If you follow John Mueller's suggestion not to mix canonical with noindex, then you can set `MetaTags.config.skip_canonical_links_on_noindex = true` and we'll handle it for you.
412
+ > If your goal is duplicate consolidation, prefer a canonical URL over `noindex`. If you do not want to mix canonical with `noindex`, set `MetaTags.config.skip_canonical_links_on_noindex = true`.
405
413
 
406
414
  ```ruby
407
415
  set_meta_tags canonical: "http://yoursite.com/canonical/url"
@@ -412,6 +420,7 @@ Further reading:
412
420
 
413
421
  - [About rel="canonical"](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139394)
414
422
  - [Canonicalization](http://www.google.com/support/webmasters/bin/answer.py?hl=en&answer=139066)
423
+ - [Google Search Central: canonicalization and duplicate URLs](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls)
415
424
 
416
425
  ### Icon
417
426
 
@@ -467,7 +476,7 @@ Further reading:
467
476
 
468
477
  ### Pagination links
469
478
 
470
- Previous and next links indicate the relationship between individual URLs. Using these attributes is a strong hint to Google that you want us to treat these pages as a logical sequence.
479
+ Previous and next links can describe a paginated sequence for browsers, feed readers, or custom consumers that still read them. Google no longer uses `rel="prev"` and `rel="next"` as an indexing signal, so treat them as optional interoperability metadata, not core SEO guidance.
471
480
 
472
481
  ```ruby
473
482
  set_meta_tags prev: "http://yoursite.com/url?page=1"
@@ -480,10 +489,11 @@ Further reading:
480
489
 
481
490
  - [Pagination](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1663744)
482
491
  - [Pagination with rel="next" and rel="prev"](http://googlewebmastercentral.blogspot.ca/2011/09/pagination-with-relnext-and-relprev.html)
492
+ - [Google Search Central: pagination, incremental page loading, and infinite scroll](https://developers.google.com/search/docs/specialty/ecommerce/pagination-and-incremental-page-loading)
483
493
 
484
494
  ### image_src links
485
495
 
486
- Basically, when you submit/share this to Facebook, it helps Facebook determine which image to put next to the link. If this is not present, Facebook tries to put in the first image it finds on the page, which may not be the best one to represent your site.
496
+ `image_src` is a legacy share hint. Modern social sharing generally relies on Open Graph images and platform-specific card tags instead.
487
497
 
488
498
  ```ruby
489
499
  set_meta_tags image_src: "http://yoursite.com/icons/icon_32.png"
@@ -492,7 +502,7 @@ set_meta_tags image_src: "http://yoursite.com/icons/icon_32.png"
492
502
 
493
503
  ### amphtml links
494
504
 
495
- AMP is a method of building web pages for static content that renders quickly. If you have two versions of a page - non-AMP and AMP - you can link the AMP version from the normal one using the `amphtml` tag:
505
+ If your application still serves AMP pages, you can link the AMP version from the canonical page with `amphtml`. This is an optional legacy integration, not a general SEO requirement.
496
506
 
497
507
  ```ruby
498
508
  set_meta_tags amphtml: url_for(format: :amp, only_path: false)
@@ -501,8 +511,7 @@ set_meta_tags amphtml: url_for(format: :amp, only_path: false)
501
511
 
502
512
  To link back to the normal version, use the `canonical` tag.
503
513
 
504
- - [What Is AMP?](https://www.ampproject.org/learn/about-amp/)
505
- - [Make Your Page Discoverable](https://www.ampproject.org/docs/guides/discovery)
514
+ - [AMP documentation](https://amp.dev/documentation/)
506
515
 
507
516
  ### Manifest links
508
517
 
@@ -648,11 +657,13 @@ set_meta_tags article: {
648
657
  Further reading:
649
658
 
650
659
  - [Open Graph protocol](http://developers.facebook.com/docs/opengraph/)
660
+ - [Open Graph protocol](https://ogp.me/)
651
661
  - [Must-Have Social Meta Tags for Twitter, Google+, Facebook and More](https://moz.com/blog/meta-data-templates-123)
662
+ - [X for Websites documentation](https://developer.x.com/en/docs/x-for-websites)
652
663
 
653
664
  ### Twitter Cards
654
665
 
655
- Twitter cards make it possible for you to attach media experiences to Tweets that link to your content. There are 3 card types (summary, photo, and player). Here's an example for summary:
666
+ X cards let links shared on X show richer previews. The metadata namespace is still `twitter:*`. Here is a simple summary card example:
656
667
 
657
668
  ```ruby
658
669
  set_meta_tags twitter: {
@@ -663,46 +674,50 @@ set_meta_tags twitter: {
663
674
  # <meta name="twitter:site" content="@username">
664
675
  ```
665
676
 
666
- Take into consideration that if you're already using OpenGraph to describe data on your page, it’s easy to generate a Twitter card without duplicating your tags and data. When the Twitter card processor looks for tags on your page, it first checks for the Twitter property, and if not present, falls back to the supported Open Graph property. This allows both to be defined on the page independently and minimizes the amount of duplicate markup required to describe your content and experience.
677
+ If you already publish Open Graph tags, you can often keep the X-specific tags minimal. Many consumers fall back to supported Open Graph fields when X-specific fields are missing.
667
678
 
668
- When you need to generate a [Twitter Photo card](https://dev.twitter.com/docs/cards/types/photo-card), the `twitter:image` property is a string, while image dimensions are specified using `twitter:image:width` and `twitter:image:height`, or a `Hash` object in terms of MetaTags gems. There is a special syntax to make this work:
679
+ When you need to generate nested `twitter:image:*` tags, the `twitter:image` property is a string while sub-properties can be expressed as a `Hash` in MetaTags:
669
680
 
670
681
  ```ruby
671
682
  set_meta_tags twitter: {
672
- card: "photo",
683
+ card: "summary_large_image",
673
684
  image: {
674
685
  _: "http://example.com/1.png",
675
686
  width: 100,
676
- height: 100
687
+ height: 100,
688
+ alt: "Cover image"
677
689
  }
678
690
  }
679
- # <meta name="twitter:card" content="photo">
691
+ # <meta name="twitter:card" content="summary_large_image">
680
692
  # <meta name="twitter:image" content="http://example.com/1.png">
681
693
  # <meta name="twitter:image:width" content="100">
682
694
  # <meta name="twitter:image:height" content="100">
695
+ # <meta name="twitter:image:alt" content="Cover image">
683
696
  ```
684
697
 
685
698
  A special parameter `itemprop` can be used on an "anonymous" tag "\_" to generate the "itemprop" HTML attribute:
686
699
 
687
700
  ```ruby
688
701
  set_meta_tags twitter: {
689
- card: "photo",
702
+ card: "summary_large_image",
690
703
  image: {
691
704
  _: "http://example.com/1.png",
692
705
  width: 100,
693
706
  height: 100,
707
+ alt: "Cover image",
694
708
  itemprop: "image"
695
709
  }
696
710
  }
697
- # <meta name="twitter:card" content="photo">
711
+ # <meta name="twitter:card" content="summary_large_image">
698
712
  # <meta name="twitter:image" content="http://example.com/1.png" itemprop="image">
699
713
  # <meta name="twitter:image:width" content="100">
700
714
  # <meta name="twitter:image:height" content="100">
715
+ # <meta name="twitter:image:alt" content="Cover image">
701
716
  ```
702
717
 
703
718
  Further reading:
704
719
 
705
- - [Twitter Cards Documentation](https://dev.twitter.com/cards/)
720
+ - [X for Websites documentation](https://developer.x.com/en/docs/x-for-websites)
706
721
 
707
722
  ### App Links
708
723
 
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MetaTags
4
+ # Rails generators for MetaTags.
4
5
  module Generators
6
+ # Installs the default MetaTags initializer into a Rails application.
5
7
  class InstallGenerator < Rails::Generators::Base
6
8
  desc "Copy MetaTags default files"
7
9
  source_root File.expand_path("templates", __dir__)
8
10
 
11
+ # Copies the default MetaTags initializer template.
12
+ #
13
+ # @return [void]
9
14
  def copy_config
10
15
  template "config/initializers/meta_tags.rb"
11
16
  end
@@ -22,15 +22,16 @@ MetaTags.configure do |config|
22
22
  # Set to nil or 0 to remove limits.
23
23
  # config.description_limit = 300
24
24
 
25
- # Maximum length of the keywords meta tag. Default is 255.
25
+ # Legacy compatibility: maximum length of the keywords meta tag.
26
+ # Most search engines ignore this tag. Default is 255.
26
27
  # config.keywords_limit = 255
27
28
 
28
- # Default separator for keywords meta tag (used when an Array passed with
29
- # the list of keywords). Default is ", ".
29
+ # Legacy compatibility: default separator for the keywords meta tag
30
+ # when an Array is passed. Default is ", ".
30
31
  # config.keywords_separator = ', '
31
32
 
32
- # When true, keywords will be converted to lowercase, otherwise they will
33
- # appear on the page as is. Default is true.
33
+ # Legacy compatibility: when true, keywords will be converted to lowercase.
34
+ # Otherwise they will appear on the page as is. Default is true.
34
35
  # config.keywords_lowercase = true
35
36
 
36
37
  # When true, the output will not include new line characters between meta tags.
@@ -24,7 +24,7 @@ module MetaTags
24
24
  # Keywords separator - a string to join keywords with.
25
25
  attr_accessor :keywords_separator
26
26
 
27
- # Should keywords forced into lowercase?
27
+ # Should keywords be forced into lowercase?
28
28
  attr_accessor :keywords_lowercase
29
29
 
30
30
  # Switches between open (<meta ... >) and closed (<meta ... />) meta tags.
@@ -35,13 +35,14 @@ module MetaTags
35
35
  # Default is false.
36
36
  attr_accessor :minify_output
37
37
 
38
- # Custom meta tags that should use `property` attribute instead of `name`
39
- # - an array of strings or symbols representing their names or name-prefixes.
38
+ # Custom meta tags that should use the `property` attribute instead of `name`.
39
+ # An array of strings or symbols representing their names or name prefixes.
40
40
  attr_reader :property_tags
41
41
 
42
- # Configure whenever Meta-Tags should skip canonicals on pages with noindex: true
43
- # "shouldn't mix noindex & rel=canonical comes from: they're very contradictory pieces of information for us."
44
- # - John Mueller (Webmaster Trends Analyst at Google)
42
+ # Configure whether MetaTags should skip canonical links on pages with
43
+ # `noindex: true`.
44
+ # John Mueller has noted that mixing `noindex` and `rel=canonical` sends
45
+ # contradictory signals.
45
46
  # https://www.reddit.com/r/TechSEO/comments/8yahdr/2_questions_about_the_canonical_tag/e2dey9i/
46
47
  attr_accessor :skip_canonical_links_on_noindex
47
48
 
@@ -50,16 +51,20 @@ module MetaTags
50
51
  reset_defaults!
51
52
  end
52
53
 
54
+ # Returns the default meta tag prefixes and names that use `property`.
55
+ #
56
+ # @return [Array<String>] default property tag names.
53
57
  def default_property_tags
54
58
  [
55
- # App Link metadata https://developers.facebook.com/docs/applinks/metadata-reference
59
+ # App Links metadata https://developers.facebook.com/docs/applinks/metadata-reference
56
60
  "al",
57
61
  # Open Graph Markup https://developers.facebook.com/docs/sharing/webmasters#markup
58
62
  "fb",
59
63
  "og",
60
- # Facebook OpenGraph Object Types https://developers.facebook.com/docs/reference/opengraph
61
- # Note that these tags are used in a regex, so including e.g. 'restaurant' will affect
62
- # 'restaurant:category', 'restaurant:price_rating', and anything else under that namespace.
64
+ # Facebook Open Graph object types https://developers.facebook.com/docs/reference/opengraph
65
+ # These tags are matched as exact property names or namespace prefixes, so e.g.
66
+ # 'restaurant' affects 'restaurant:category', 'restaurant:price_rating', and other
67
+ # properties under that namespace.
63
68
  "article",
64
69
  "book",
65
70
  "books",
@@ -75,10 +80,16 @@ module MetaTags
75
80
  ].freeze
76
81
  end
77
82
 
83
+ # Indicates whether meta tags should be rendered with open tag syntax.
84
+ #
85
+ # @return [Boolean] true when open meta tags are enabled.
78
86
  def open_meta_tags?
79
87
  !!open_meta_tags
80
88
  end
81
89
 
90
+ # Restores the default configuration values.
91
+ #
92
+ # @return [void]
82
93
  def reset_defaults!
83
94
  @title_limit = 70
84
95
  @truncate_site_title_first = false
@@ -4,13 +4,12 @@ module MetaTags
4
4
  # Represents an HTML meta tag with content (<tag></tag>).
5
5
  # Content should be passed as a `:content` attribute.
6
6
  class ContentTag < Tag
7
- # Render tag into a Rails view.
7
+ # Renders the tag in a Rails view.
8
8
  #
9
- # @param [ActionView::Base] view instance of a Rails view.
9
+ # @param view [ActionView::Base] instance of a Rails view.
10
10
  # @return [String] HTML string for the tag.
11
- #
12
11
  def render(view)
13
- view.content_tag(name, attributes[:content], prepare_attributes(attributes.except(:content)))
12
+ view.content_tag(name, attributes[:content], serialize_iso8601_attributes(attributes.except(:content)))
14
13
  end
15
14
  end
16
15
  end
@@ -2,18 +2,20 @@
2
2
 
3
3
  module MetaTags
4
4
  # Contains methods to use in controllers.
5
- #
6
5
  # You can define several instance variables to set meta tags:
7
6
  # @page_title = 'Member Login'
8
7
  # @page_description = 'Member login page.'
9
- # @page_keywords = 'Site, Login, Members'
10
- #
11
- # Also you can use {#set_meta_tags} method, that have the same parameters
12
- # as {ViewHelper#set_meta_tags}.
13
- #
8
+ # @page_keywords = 'Site, Login, Members' # legacy keywords tag
9
+ # You can also use the {#set_meta_tags} method, which has the same
10
+ # parameters as {ViewHelper#set_meta_tags}.
14
11
  module ControllerHelper
15
- # Processes the <tt>@page_title</tt>, <tt>@page_keywords</tt>, and
16
- # <tt>@page_description</tt> instance variables and calls +render+.
12
+ # Processes the <tt>@page_title</tt>, <tt>@page_description</tt>, and
13
+ # legacy <tt>@page_keywords</tt> instance variables and calls +render+.
14
+ #
15
+ # @param args [Array<Object>] positional arguments forwarded to +render+.
16
+ # @param block [Proc, nil] optional block forwarded to +render+.
17
+ # @yield optional block forwarded to +render+.
18
+ # @yieldreturn [Object] result of the render block.
17
19
  def render(*args, &block)
18
20
  meta_tags[:title] = @page_title if defined?(@page_title) && @page_title
19
21
  meta_tags[:keywords] = @page_keywords if defined?(@page_keywords) && @page_keywords
@@ -24,6 +26,7 @@ module MetaTags
24
26
 
25
27
  # Set meta tags for the page.
26
28
  #
29
+ # @param meta_tags [Hash] list of meta tags to merge into the page state.
27
30
  # See <tt>MetaTags::ViewHelper#set_meta_tags</tt> for details.
28
31
  def set_meta_tags(meta_tags)
29
32
  self.meta_tags.update(meta_tags)