meta-tags 2.19.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MetaTags: a gem to make your Rails application SEO-friendly
2
2
 
3
- [![CircleCI](https://circleci.com/gh/kpumuk/meta-tags.svg?style=shield)](https://circleci.com/gh/kpumuk/meta-tags)
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)
5
5
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
6
6
  [![Code Climate](https://codeclimate.com/github/kpumuk/meta-tags/badges/gpa.svg)](https://codeclimate.com/github/kpumuk/meta-tags)
@@ -12,13 +12,10 @@ Search Engine Optimization (SEO) plugin for Ruby on Rails applications.
12
12
 
13
13
  ## Ruby on Rails
14
14
 
15
- MetaTags main branch fully supports Ruby on Rails 5.1+, and is tested against all
16
- major Rails releases up to 7.1.
15
+ The MetaTags main branch fully supports Ruby on Rails 6.0+ and is tested against all major Ruby on Rails releases.
17
16
 
18
- Ruby versions older than 2.7 are no longer officially supported.
19
-
20
- _Please note_ that we no longer support Ruby versions older than 2.6.0 and
21
- Ruby on Rails older than 5.1, because they reached their [End of Life](https://endoflife.date/ruby).
17
+ > [!NOTE]
18
+ > We no longer support Ruby versions older than 3.0 and Ruby on Rails older than 6.0 since they reached their end of life (see [Ruby](https://endoflife.date/ruby) and [Ruby on Rails](https://endoflife.date/rails)).
22
19
 
23
20
  ## Installation
24
21
 
@@ -32,23 +29,15 @@ And run `bundle install` command.
32
29
 
33
30
  ## Configuration
34
31
 
35
- MetaTags follows best-practices for meta tags. Although default limits for
36
- truncation have recommended values, you can change them to reflect your own
37
- preferences. Keywords are converted to lowercase by default, but this is also
38
- configurable.
32
+ 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.
39
33
 
40
- To override the defaults, create an initializer
41
- `config/initializers/meta_tags.rb` using the following command:
34
+ To override the defaults, create an initializer `config/initializers/meta_tags.rb` using the following command:
42
35
 
43
36
  ```bash
44
37
  rails generate meta_tags:install
45
38
  ```
46
39
 
47
- By default meta tags are rendered with the key `name`. Since, some meta tags are
48
- required to use `property` instead (like Facebook Open Graph object), MetaTags gem
49
- allows to configure which tags to render with `property` attribute. By default
50
- the pre-configured list includes all possible Facebook Open Graph object types, but
51
- you can add your own in case you need it.
40
+ By default, meta tags are rendered with the key `name`. However, some meta tags are required to use `property` instead (like Facebook Open Graph object). The MetaTags gem allows you to configure which tags to render with the `property` attribute. The pre-configured list includes all possible Facebook Open Graph object types by default, but you can add your own in case you need it.
52
41
 
53
42
  ## MetaTags Usage
54
43
 
@@ -77,11 +66,14 @@ When views are rendered, the page title will be included in the right spots:
77
66
  </body>
78
67
  ```
79
68
 
80
- You can find allowed options for `display_meta_tags` method below.
69
+ You can find allowed options for the `display_meta_tags` method below.
70
+
71
+ > [!IMPORTANT]
72
+ > You **must** use `display_meta_tags` in the layout files to render the meta tags. In the views, you will instead use `set_meta_tags`, which accepts the same arguments but does not render anything in the place where it is called.
81
73
 
82
74
  ### Using MetaTags in controller
83
75
 
84
- You can define following instance variables:
76
+ You can define the following instance variables:
85
77
 
86
78
  ```ruby
87
79
  @page_title = "Member Login"
@@ -89,7 +81,7 @@ You can define following instance variables:
89
81
  @page_keywords = "Site, Login, Members"
90
82
  ```
91
83
 
92
- Also you could use `set_meta_tags` method to define all meta tags simultaneously:
84
+ Also, you could use the `set_meta_tags` method to define all meta tags simultaneously:
93
85
 
94
86
  ```ruby
95
87
  set_meta_tags(
@@ -99,11 +91,11 @@ set_meta_tags(
99
91
  )
100
92
  ```
101
93
 
102
- You can find allowed options for `set_meta_tags` method below.
94
+ You can find the allowed options for the `set_meta_tags` method below.
103
95
 
104
96
  ### Using MetaTags in view
105
97
 
106
- To set meta tags you can use following methods:
98
+ To set meta tags, you can use the following methods:
107
99
 
108
100
  ```erb
109
101
  <% title "Member Login" %>
@@ -114,7 +106,7 @@ To set meta tags you can use following methods:
114
106
  <% refresh 3 %>
115
107
  ```
116
108
 
117
- Also there is `set_meta_tags` method exists:
109
+ Also, the `set_meta_tags` method exists:
118
110
 
119
111
  ```erb
120
112
  <%
@@ -126,7 +118,7 @@ Also there is `set_meta_tags` method exists:
126
118
  %>
127
119
  ```
128
120
 
129
- You can pass an object that implements `#to_meta_tags` method and returns a Hash:
121
+ You can pass an object that implements the `#to_meta_tags` method and returns a Hash:
130
122
 
131
123
  ```ruby
132
124
  class Document < ApplicationRecord
@@ -142,7 +134,7 @@ end
142
134
  set_meta_tags @document
143
135
  ```
144
136
 
145
- The `title` method returns title itself, so you can use it to show the title
137
+ The `title` method returns the title itself, so you can use it to show the title
146
138
  somewhere on the page:
147
139
 
148
140
  ```erb
@@ -159,30 +151,30 @@ If you want to set the title and display another text, use this:
159
151
 
160
152
  Use these options to customize the title format:
161
153
 
162
- | Option | Description |
163
- | -------------- | -------------------------------------------------------------------------------------------------------------------- |
164
- | `:site` | site title |
165
- | `:title` | page title |
166
- | `:description` | page description |
167
- | `:keywords` | page keywords |
168
- | `:charset` | page character set |
169
- | `:prefix` | text between site name and separator |
170
- | `:separator` | text used to separate website name from page title |
171
- | `:suffix` | text between separator and page title |
172
- | `:lowercase` | when true, the page name will be lowercase |
173
- | `:reverse` | when true, the page and site names will be reversed |
174
- | `:noindex` | add noindex meta tag; when true, "robots" will be used; accepts a string with a robot name, or an array of strings |
175
- | `:index` | add index meta tag; when true, "robots" will be used; accepts a string with a robot name, or an array of strings |
176
- | `:nofollow` | add nofollow meta tag; when true, "robots" will be used; accepts a string with a robot name, or an array of strings |
177
- | `:follow` | add follow meta tag; when true, "robots" will be used; accepts a string with a robot name, or an array of strings |
178
- | `:noarchive` | add noarchive meta tag; when true, "robots" will be used; accepts a string with a robot name, or an array of strings |
179
- | `:canonical` | add canonical link tag |
180
- | `:prev` | add prev link tag |
181
- | `:next` | add next link tag |
182
- | `:image_src` | add image_src link tag |
183
- | `:og` | add Open Graph tags (Hash) |
184
- | `:twitter` | add Twitter tags (Hash) |
185
- | `:refresh` | refresh interval and optionally url to redirect to |
154
+ | Option | Description |
155
+ | -------------- | ------------------------------------------------------------------------------------------------------------------- |
156
+ | `:site` | Site title |
157
+ | `:title` | Page title |
158
+ | `:description` | Page description |
159
+ | `:keywords` | Page keywords |
160
+ | `:charset` | Page character set |
161
+ | `:prefix` | Text between site name and separator |
162
+ | `:separator` | Text used to separate the website name from the page title |
163
+ | `:suffix` | Text between separator and page title |
164
+ | `:lowercase` | When true, the page name will be lowercase |
165
+ | `:reverse` | When true, the page and site names will be reversed |
166
+ | `:noindex` | Add noindex meta tag; when true, "robots" will be used; accepts a string with a robot name or an array of strings |
167
+ | `:index` | Add index meta tag; when true, "robots" will be used; accepts a string with a robot name or an array of strings |
168
+ | `:nofollow` | Add nofollow meta tag; when true, "robots" will be used; accepts a string with a robot name or an array of strings |
169
+ | `:follow` | Add follow meta tag; when true, "robots" will be used; accepts a string with a robot name or an array of strings |
170
+ | `:noarchive` | Add noarchive meta tag; when true, "robots" will be used; accepts a string with a robot name or an array of strings |
171
+ | `:canonical` | Add canonical link tag |
172
+ | `:prev` | Add prev link tag |
173
+ | `:next` | Add next link tag |
174
+ | `:image_src` | Add image_src link tag |
175
+ | `:og` | Add Open Graph tags (Hash) |
176
+ | `:twitter` | Add Twitter tags (Hash) |
177
+ | `:refresh` | Refresh interval and optionally URL to redirect to |
186
178
 
187
179
  And here are a few examples to give you ideas.
188
180
 
@@ -206,22 +198,20 @@ set_meta_tags title: ["part1", "part2"], reverse: true, site: "site"
206
198
  # part2 | part1 | site
207
199
  ```
208
200
 
209
- Keywords can be passed as string of comma-separated values, or as an array:
201
+ Keywords can be passed as a string of comma-separated values or as an array:
210
202
 
211
203
  ```ruby
212
204
  set_meta_tags keywords: ["tag1", "tag2"]
213
205
  # tag1, tag2
214
206
  ```
215
207
 
216
- Description is a string (HTML will be stripped from output string).
208
+ The description is a string (HTML will be stripped from the output string).
217
209
 
218
210
  ### Mirrored values
219
211
 
220
- Sometimes, it is desirable to mirror meta tag values down into namespaces. A
221
- common use case is when you want open graph's `og:title` to be identical to
222
- the `title`.
212
+ Sometimes, it is desirable to mirror meta tag values down into namespaces. A common use case is when you want the open graph's `og:title` to be identical to the `title`.
223
213
 
224
- Say, you have the following in your application layout:
214
+ Let's say you have the following code in your application layout:
225
215
 
226
216
  ```ruby
227
217
  display_meta_tags og: {
@@ -230,40 +220,48 @@ display_meta_tags og: {
230
220
  }
231
221
  ```
232
222
 
233
- The value of `og[:title]` is a symbol and therefore references the value of the
234
- top level `title` meta tag. With the following in any view:
223
+ The value of `og[:title]` is a symbol, which refers to the value of the top-level `title` meta tag. In any view with the following code:
235
224
 
236
225
  ```ruby
237
226
  title "my great view"
238
227
  ```
239
228
 
240
- You get this open graph meta tag for free:
229
+ You will get this open graph meta tag automatically:
241
230
 
242
231
  ```html
243
232
  <meta property="og:title" content="my great view"></meta>
244
233
  ```
245
234
 
246
- Please note, that title does not include site. If you need to reference the exact
247
- value rendered in the `<title>` meta tag, use `:full_title`.
235
+ > [!NOTE]
236
+ > The `title` does not include the site name. If you need to reference the exact value rendered in the `<title>` meta tag, use `:full_title`.
237
+
238
+ ### Using with Turbo
239
+
240
+ [Turbo](https://github.com/hotwired/turbo) is a simple solution for getting the performance benefits of a single-page application without the added complexity of a client-side JavaScript framework. MetaTags supports Turbo out of the box, so no configuration is necessary.
241
+
242
+ In order to update the page title, you can use the following trick. First, set the ID for the `<title>` HTML tag using MetaTags configuration in your initializer `config/initializers/meta_tags.rb`:
243
+
244
+ ```ruby
245
+ MetaTags.configure do |config|
246
+ config.title_tag_attributes = {id: "page-title"}
247
+ end
248
+ ````
248
249
 
249
- ### Using with Turbolinks
250
+ Now in your turbo frame, you can update the title using a turbo stream:
250
251
 
251
- [Turbolinks](https://github.com/turbolinks/turbolinks) is a simple solution for getting
252
- the performance benefits of a single-page application without the added complexity of a
253
- client-side JavaScript framework. MetaTags supports Turbolinks out of the box, no
254
- configuration is necessary.
252
+ ```html
253
+ <turbo-frame ...>
254
+ <turbo-stream action="update" target="page-title">
255
+ <template>My new title</template>
256
+ </turbo-stream>
257
+ </turbo-frame>
258
+ ```
255
259
 
256
260
  ### Using with pjax
257
261
 
258
- [jQuery.pjax](https://github.com/defunkt/jquery-pjax) is a nice solution for navigation
259
- without full page reload. The main difference is that layout file will not be rendered,
260
- so page title will not change. To fix this, when using a page fragment, pjax will check
261
- the fragment DOM element for a `title` or `data-title` attribute and use any value it finds.
262
+ [jQuery.pjax](https://github.com/defunkt/jquery-pjax) is a nice solution for navigation without a full-page reload. The main difference is that the layout file will not be rendered, so the page title will not change. To fix this, when using a page fragment, pjax will check the fragment DOM element for a `title` or `data-title` attribute and use any value it finds.
262
263
 
263
- MetaTags simplifies this with `display_title` method, which returns fully resolved
264
- page title (include site, prefix/suffix, etc.) But in this case you will have to
265
- set default parameters (e.g, `:site`) both in layout file and in your views. To minimize
266
- code duplication, you can define a helper in `application_helper.rb`:
264
+ MetaTags simplifies this with the `display_title` method, which returns the fully resolved page title (including site, prefix/suffix, etc.). But in this case, you will have to set default parameters (e.g., `:site`) both in the layout file and in your views. To minimize code duplication, you can define a helper in `application_helper.rb`:
267
265
 
268
266
  ```ruby
269
267
  def default_meta_tags
@@ -276,7 +274,7 @@ def default_meta_tags
276
274
  end
277
275
  ```
278
276
 
279
- Then in your layout file use:
277
+ Then, in your layout file, use:
280
278
 
281
279
  ```erb
282
280
  <%= display_meta_tags(default_meta_tags) %>
@@ -285,7 +283,7 @@ Then in your layout file use:
285
283
  And in your pjax templates:
286
284
 
287
285
  ```erb
288
- <!-- set title here, so we can use it both in "display_title" and in "title" -->
286
+ <!-- set title here so we can use it both in "display_title" and in "title" -->
289
287
  <% title "My Page title" %>
290
288
  <%= content_tag :div, data: { title: display_title(default_meta_tags) } do %>
291
289
  <h1><%= title %></h1>
@@ -297,9 +295,7 @@ And in your pjax templates:
297
295
 
298
296
  ### Titles
299
297
 
300
- Page titles are very important for Search engines. The titles in the
301
- browser are displayed in the title bar. The search engines look at
302
- the title bar to determine what the page is all about.
298
+ 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.
303
299
 
304
300
  ```ruby
305
301
  set_meta_tags title: "Member Login"
@@ -310,7 +306,7 @@ set_meta_tags site: "Site Title", title: "Member Login", reverse: true
310
306
  # <title>Member Login | Site Title</title>
311
307
  ```
312
308
 
313
- Recommended title tag length: up to <b>70 characters</b>, <b>10 words</b>.
309
+ Recommended title tag length: up to **70 characters** in **10 words**.
314
310
 
315
311
  Further reading:
316
312
 
@@ -318,17 +314,16 @@ Further reading:
318
314
 
319
315
  ### Description
320
316
 
321
- Description tags are called meta tags as they are not displayed by the
322
- browsers unlike the titles. However, these descriptions may be displayed by
323
- some search engines. They are used to describe the contents of a page in
324
- 2 or 3 sentences.
317
+ 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
+
319
+ Below is an example of how to set a description tag using Ruby:
325
320
 
326
321
  ```ruby
327
- set_meta_tags description: "All text about keywords, other keywords"
328
- # <meta name="description" content="All text about keywords, other keywords">
322
+ set_meta_tags description: "This is a sample description"
323
+ # <meta name="description" content="This is a sample description">
329
324
  ```
330
325
 
331
- Recommended description tag length: up to <b>300 characters</b>.
326
+ It is advisable to limit the length of the description tag to **300 characters**.
332
327
 
333
328
  Further reading:
334
329
 
@@ -337,24 +332,21 @@ Further reading:
337
332
 
338
333
  ### Keywords
339
334
 
340
- Meta keywords tag are used to place your keywords that you think a
341
- surfer would search in Search engines. Repeating keywords unnecessarily
342
- would be considered spam and you may get permanently banned from SERP's
335
+ 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).
343
336
 
344
337
  ```ruby
345
- set_meta_tags keywords: %w[keyword1 Keyword2 KeyWord3]
338
+ set_meta_tags keywords: %w[keyword1 keyword2 keyword3]
346
339
  # <meta name="keywords" content="keyword1, keyword2, keyword3">
347
340
  ```
348
341
 
349
- Recommended keywords tag length: up to <b>255 characters</b>, <b>20 words</b>.
342
+ It is recommended to keep the length of the keywords tag under **255 characters** or **20 words**.
350
343
 
351
- **Please note**, that both Google and Bing publicly indicated that keywords
352
- meta tags is completely ignored.
344
+ > [!NOTE]
345
+ > Both Google and Bing have publicly stated that they completely ignore keywords meta tags.
353
346
 
354
347
  ### Noindex
355
348
 
356
- By using the noindex meta tag, you can signal to search engines to not
357
- include specific pages in their indexes.
349
+ By using the noindex meta tag, you can signal to search engines not to include specific pages in their indexes.
358
350
 
359
351
  ```ruby
360
352
  set_meta_tags noindex: true
@@ -372,7 +364,7 @@ Further reading:
372
364
 
373
365
  ### Index
374
366
 
375
- Although it is not required to add "index" to "robots" as it is default value for Google, some SEO specialists recommend to add it to website
367
+ 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.
376
368
 
377
369
  ```ruby
378
370
  set_meta_tags index: true
@@ -381,10 +373,7 @@ set_meta_tags index: true
381
373
 
382
374
  ### Nofollow
383
375
 
384
- Nofollow meta tag tells a search engine not to follow the links on a specific
385
- page. It's entirely likely that a robot might find the same links on some
386
- other page without a nofollow (perhaps on some other site), and so
387
- still arrives at your undesired page.
376
+ Nofollow meta tags tell a search engine not to follow the links on a specific page. It is entirely possible that a robot might find the same links on another page without a nofollow attribute, perhaps on another site, and still arrive at your undesired page.
388
377
 
389
378
  ```ruby
390
379
  set_meta_tags nofollow: true
@@ -400,24 +389,21 @@ Further reading:
400
389
 
401
390
  ### Follow
402
391
 
403
- Follow will work with Noindex meta tag
392
+ You can use the Noindex meta tag in conjunction with Follow.
404
393
 
405
394
  ```ruby
406
395
  set_meta_tags noindex: true, follow: true
407
396
  # <meta name="robots" content="noindex, follow">
408
397
  ```
409
398
 
410
- It will not look at this page but will crawl through the rest of the pages on
411
- your website.
399
+ This tag will prevent search engines from indexing this specific page, but it will still allow them to crawl and index the remaining pages on your website.
412
400
 
413
401
  ### Canonical URL
414
402
 
415
- Canonical link element tells a search engine what is the canonical or main URL
416
- for a content which have multiple URLs. The search engine will always return
417
- that URL, and link popularity and authority will be applied to that URL.
403
+ 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.
418
404
 
419
- Note: If you like follow a hint of John Mueller that you shouldn't mix canonical with noindex, then you can
420
- set `MetaTags.config.skip_canonical_links_on_noindex = true` and we'll handle it for you.
405
+ > [!NOTE]
406
+ > 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.
421
407
 
422
408
  ```ruby
423
409
  set_meta_tags canonical: "http://yoursite.com/canonical/url"
@@ -431,9 +417,7 @@ Further reading:
431
417
 
432
418
  ### Icon
433
419
 
434
- A favicon (short for Favorite icon), also known as a shortcut icon, Web site
435
- icon, tab icon or bookmark icon, is a file containing one or more small icons,
436
- most commonly 16×16 pixels, associated with a particular website or web page.
420
+ A favicon (short for Favorite icon), also known as a shortcut icon, website icon, tab icon, or bookmark icon, is a file containing one or more small icons, most commonly 16x16 pixels, associated with a particular website or web page.
437
421
 
438
422
  ```ruby
439
423
  set_meta_tags icon: "/favicon.ico"
@@ -455,8 +439,7 @@ Further reading:
455
439
 
456
440
  ### Multi-regional and multilingual URLs, RSS and mobile links
457
441
 
458
- Alternate link elements tell a search engine when there is content that's
459
- translated or targeted to users in a certain region.
442
+ Alternate link elements tell a search engine when there is content that's translated or targeted to users in a certain region.
460
443
 
461
444
  ```ruby
462
445
  set_meta_tags alternate: {"fr" => "http://yoursite.fr/alternate/url"}
@@ -486,9 +469,7 @@ Further reading:
486
469
 
487
470
  ### Pagination links
488
471
 
489
- Previous and next links indicate indicate the relationship between individual
490
- URLs. Using these attributes is a strong hint to Google that you want us to
491
- treat these pages as a logical sequence.
472
+ 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.
492
473
 
493
474
  ```ruby
494
475
  set_meta_tags prev: "http://yoursite.com/url?page=1"
@@ -504,10 +485,7 @@ Further reading:
504
485
 
505
486
  ### image_src links
506
487
 
507
- Basically, when you submit/share this to Facebook , this helps Facebook determine
508
- which image to put next to the link. If this is not present, Facebook tries to
509
- put in the first image it finds on the page, which may not be the best one to
510
- represent your site.
488
+ 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.
511
489
 
512
490
  ```ruby
513
491
  set_meta_tags image_src: "http://yoursite.com/icons/icon_32.png"
@@ -516,22 +494,22 @@ set_meta_tags image_src: "http://yoursite.com/icons/icon_32.png"
516
494
 
517
495
  ### amphtml links
518
496
 
519
- AMP is a way to build web pages for static content that render fast. If you have
520
- two versions of the page – non-AMP and AMP, you can link the AMP version from
521
- normal one using `amphtml` tag:
497
+ 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:
522
498
 
523
499
  ```ruby
524
500
  set_meta_tags amphtml: url_for(format: :amp, only_path: false)
525
501
  # <link rel="amphtml" href="https://www.example.com/document.amp">
526
502
  ```
527
503
 
528
- To link back to normal version, use `canonical`.
504
+ To link back to the normal version, use the `canonical` tag.
529
505
 
530
506
  - [What Is AMP?](https://www.ampproject.org/learn/about-amp/)
531
507
  - [Make Your Page Discoverable](https://www.ampproject.org/docs/guides/discovery)
532
508
 
533
509
  ### Manifest links
534
510
 
511
+ By including the `rel="manifest"` attribute in the `<link>` element of an HTML page, you can specify the location of the manifest file that describes the web application. This allows the browser to understand that the web page is an application and to provide features like offline access and the ability to add the application to the home screen of a mobile device.
512
+
535
513
  ```ruby
536
514
  set_meta_tags manifest: "manifest.json"
537
515
  # <link rel="manifest" href="manifest.json">
@@ -541,12 +519,7 @@ set_meta_tags manifest: "manifest.json"
541
519
 
542
520
  ### Refresh interval and redirect URL
543
521
 
544
- Meta refresh is a method of instructing a web browser to automatically
545
- refresh the current web page or frame after a given time interval. It is also
546
- possible to instruct the browser to fetch a different URL when the page is
547
- refreshed, by including the alternative URL in the content parameter. By
548
- setting the refresh time interval to zero (or a very low value), this allows
549
- meta refresh to be used as a method of URL redirection.
522
+ Meta refresh is a method of instructing a web browser to automatically refresh the current web page or frame after a given time interval. It is also possible to instruct the browser to fetch a different URL when the page is refreshed, by including the alternative URL in the content parameter. By setting the refresh time interval to zero (or a very low value), this allows meta refresh to be used as a method of URL redirection.
550
523
 
551
524
  ```ruby
552
525
  set_meta_tags refresh: 5
@@ -562,7 +535,7 @@ Further reading:
562
535
 
563
536
  ### Open Search
564
537
 
565
- Open Search link element to describe a search engine in a standard and accessible format.
538
+ Open Search is a link element used to describe a search engine in a standard and accessible format.
566
539
 
567
540
  ```ruby
568
541
  set_meta_tags open_search: {
@@ -579,7 +552,7 @@ Further reading:
579
552
 
580
553
  ### Hashes
581
554
 
582
- Any namespace can be built just passing any symbol name and a Hash. For example:
555
+ Any namespace can be created by simply passing a symbol name and a Hash. For example:
583
556
 
584
557
  ```ruby
585
558
  set_meta_tags foo: {
@@ -594,7 +567,7 @@ set_meta_tags foo: {
594
567
 
595
568
  ### Arrays
596
569
 
597
- Repeated meta tags can be built just using an Array inside a Hash. For example:
570
+ Repeated meta tags can be easily created by using an Array within a Hash. For example:
598
571
 
599
572
  ```ruby
600
573
  set_meta_tags og: {
@@ -606,10 +579,7 @@ set_meta_tags og: {
606
579
 
607
580
  ### Open Graph
608
581
 
609
- To turn your web pages into graph objects, you'll need to add Open Graph
610
- protocol `<meta>` tags to your webpages. The tags allow you to specify
611
- structured information about your web pages. The more information you provide, the more opportunities your web pages can be surfaced within Facebook today
612
- and in the future. Here's an example for a movie page:
582
+ To turn your web pages into graph objects, you'll need to add Open Graph protocol `<meta>` tags to your webpages. The tags allow you to specify structured information about your web pages. The more information you provide, the more opportunities your web pages can be surfaced within Facebook today and in the future. Here's an example for a movie page:
613
583
 
614
584
  ```ruby
615
585
  set_meta_tags og: {
@@ -684,8 +654,7 @@ Further reading:
684
654
 
685
655
  ### Twitter Cards
686
656
 
687
- Twitter cards make it possible for you to attach media experiences to Tweets that link to your content.
688
- There are 3 card types (summary, photo and player). Here's an example for summary:
657
+ 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:
689
658
 
690
659
  ```ruby
691
660
  set_meta_tags twitter: {
@@ -696,9 +665,9 @@ set_meta_tags twitter: {
696
665
  # <meta name="twitter:site" content="@username">
697
666
  ```
698
667
 
699
- Take in 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 for both to be defined on the page independently, and minimizes the amount of duplicate markup required to describe your content and experience.
668
+ 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.
700
669
 
701
- When you need to generate a [Twitter Photo card](https://dev.twitter.com/docs/cards/types/photo-card), `twitter:image` property is a string, while image dimensions are specified using `twitter:image:width` and `twitter:image:height`, or a `Hash` objects in terms of MetaTags gems. There is a special syntax to make this work:
670
+ 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:
702
671
 
703
672
  ```ruby
704
673
  set_meta_tags twitter: {
@@ -715,7 +684,7 @@ set_meta_tags twitter: {
715
684
  # <meta name="twitter:image:height" content="100">
716
685
  ```
717
686
 
718
- Special parameter `itemprop` can be used on a "anonymous" tag "\_" to generate "itemprop" HTML attribute:
687
+ A special parameter `itemprop` can be used on an "anonymous" tag "\_" to generate the "itemprop" HTML attribute:
719
688
 
720
689
  ```ruby
721
690
  set_meta_tags twitter: {
@@ -739,7 +708,7 @@ Further reading:
739
708
 
740
709
  ### App Links
741
710
 
742
- App Links is an open cross platform solution for deep linking to content in your mobile app. Here's an example for iOS app integration:
711
+ App Links is an open cross-platform solution for deep linking to content in your mobile app. Here's an example of iOS app integration:
743
712
 
744
713
  ```ruby
745
714
  set_meta_tags al: {
@@ -760,8 +729,7 @@ Further reading:
760
729
 
761
730
  ### Custom meta tags
762
731
 
763
- Starting from version 1.3.1, you can specify arbitrary meta tags, and they will
764
- be rendered on the page, even if meta-tags gem does not know about them.
732
+ Starting from version 1.3.1, you can specify arbitrary meta tags, and they will be rendered on the page, even if the meta-tags gem does not know about them.
765
733
 
766
734
  Example:
767
735
 
@@ -770,8 +738,7 @@ set_meta_tags author: "Dmytro Shteflyuk"
770
738
  # <meta name="author" content="Dmytro Shteflyuk">
771
739
  ```
772
740
 
773
- You can also specify value as an Array, and values will be displayed as a list
774
- of `meta` tags:
741
+ You can also specify the value as an Array, and the values will be displayed as a list of `meta` tags:
775
742
 
776
743
  ```ruby
777
744
  set_meta_tags author: ["Dmytro Shteflyuk", "John Doe"]
@@ -781,4 +748,4 @@ set_meta_tags author: ["Dmytro Shteflyuk", "John Doe"]
781
748
 
782
749
  ## Maintainers
783
750
 
784
- [Dmytro Shteflyuk](https://github.com/kpumuk), [https://kpumuk.info](http://kpumuk.info/)
751
+ [Dmytro Shteflyuk](https://github.com/kpumuk), [https://dmytro.sh](https://dmytro.sh)
data/Rakefile CHANGED
@@ -10,14 +10,6 @@ desc "Run RSpec tests"
10
10
  task test: :spec
11
11
  task default: :spec
12
12
 
13
- desc "Rebuild Circle CI configuration based on the build matrix template .circleci/config.yml.erb"
14
- task :circleci do
15
- require "erb"
16
- template_path = File.expand_path(".circleci/config.yml.erb", __dir__)
17
- config_path = File.expand_path(".circleci/config.yml", __dir__)
18
- File.write config_path, ERB.new(File.read(template_path)).result
19
- end
20
-
21
13
  module SteepRunner
22
14
  def self.run(*command)
23
15
  require "steep"
@@ -9,6 +9,15 @@ MetaTags.configure do |config|
9
9
  # When true, site title will be truncated instead of title. Default is false.
10
10
  # config.truncate_site_title_first = false
11
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
+
12
21
  # Maximum length of the page description. Default is 300.
13
22
  # Set to nil or 0 to remove limits.
14
23
  # config.description_limit = 300
@@ -6,9 +6,15 @@ module MetaTags
6
6
  # How many characters to truncate title to.
7
7
  attr_accessor :title_limit
8
8
 
9
+ # HTML attributes for the title tag.
10
+ attr_accessor :title_tag_attributes
11
+
9
12
  # Truncate site_title instead of title.
10
13
  attr_accessor :truncate_site_title_first
11
14
 
15
+ # A string or regexp separator to truncate text at a natural break.
16
+ attr_accessor :truncate_on_natural_separator
17
+
12
18
  # How many characters to truncate description to.
13
19
  attr_accessor :description_limit
14
20
 
@@ -76,6 +82,8 @@ module MetaTags
76
82
  def reset_defaults!
77
83
  @title_limit = 70
78
84
  @truncate_site_title_first = false
85
+ @truncate_on_natural_separator = " "
86
+ @title_tag_attributes = {}
79
87
  @description_limit = 300
80
88
  @keywords_limit = 255
81
89
  @keywords_separator = ", "