Class: MetaTags::Configuration
- Defined in:
- lib/meta_tags/configuration.rb,
sig/lib/meta_tags/configuration.rbs
Overview
MetaTags configuration.
Instance Attribute Summary collapse
-
#description_limit ⇒ Integer?
How many characters to truncate description to.
-
#keywords_limit ⇒ Integer
How many characters to truncate keywords to.
-
#keywords_lowercase ⇒ Boolean
Should keywords be forced into lowercase?.
-
#keywords_separator ⇒ String
Keywords separator - a string to join keywords with.
-
#minify_output ⇒ Boolean
When true, the output will not include new line characters between meta tags.
-
#open_meta_tags ⇒ Boolean
Switches between open (<meta ... >) and closed (<meta ... />) meta tags.
-
#property_tags ⇒ Array[String | Symbol]
readonly
Custom meta tags that should use the
propertyattribute instead ofname. -
#resolve_symbolic_references_in_arrays ⇒ Boolean
When true, Symbols inside nested meta tag arrays resolve as references to normalized top-level tags.
-
#skip_canonical_links_on_noindex ⇒ Boolean
Configure whether MetaTags should skip canonical links on pages with
noindex: true. -
#title_limit ⇒ Integer?
How many characters to truncate title to.
-
#title_tag_attributes ⇒ Hash[html_tag_key, html_tag_value]?
HTML attributes for the title tag.
-
#truncate_array_items_at_boundaries ⇒ Boolean
When true, multi-item arrays stop at item boundaries instead of truncating the overflowing item.
-
#truncate_on_natural_separator ⇒ String?, Regexp
A string or regexp separator to truncate text at a natural break.
-
#truncate_site_title_first ⇒ Boolean
Truncate site_title instead of title.
Instance Method Summary collapse
-
#default_property_tags ⇒ Array<String>
Returns the default meta tag prefixes and names that use
property. -
#initialize ⇒ Configuration
constructor
Initializes a new instance of Configuration class.
-
#open_meta_tags? ⇒ Boolean
Indicates whether meta tags should be rendered with open tag syntax.
-
#reset_defaults! ⇒ void
Restores the default configuration values.
Constructor Details
#initialize ⇒ Configuration
Initializes a new instance of Configuration class.
58 59 60 |
# File 'lib/meta_tags/configuration.rb', line 58 def initialize reset_defaults! end |
Instance Attribute Details
#description_limit ⇒ Integer?
How many characters to truncate description to.
23 24 25 |
# File 'lib/meta_tags/configuration.rb', line 23 def description_limit @description_limit end |
#keywords_limit ⇒ Integer
How many characters to truncate keywords to.
26 27 28 |
# File 'lib/meta_tags/configuration.rb', line 26 def keywords_limit @keywords_limit end |
#keywords_lowercase ⇒ Boolean
Should keywords be forced into lowercase?
32 33 34 |
# File 'lib/meta_tags/configuration.rb', line 32 def keywords_lowercase @keywords_lowercase end |
#keywords_separator ⇒ String
Keywords separator - a string to join keywords with.
29 30 31 |
# File 'lib/meta_tags/configuration.rb', line 29 def keywords_separator @keywords_separator end |
#minify_output ⇒ Boolean
When true, the output will not include new line characters between meta tags. Default is false.
40 41 42 |
# File 'lib/meta_tags/configuration.rb', line 40 def minify_output @minify_output end |
#open_meta_tags ⇒ Boolean
Switches between open (<meta ... >) and closed (<meta ... />) meta tags. Default is true, which means "open".
36 37 38 |
# File 'lib/meta_tags/configuration.rb', line 36 def @open_meta_tags end |
#property_tags ⇒ Array[String | Symbol] (readonly)
Custom meta tags that should use the property attribute instead of name.
An array of strings or symbols representing their names or name prefixes.
48 49 50 |
# File 'lib/meta_tags/configuration.rb', line 48 def @property_tags end |
#resolve_symbolic_references_in_arrays ⇒ Boolean
When true, Symbols inside nested meta tag arrays resolve as references to normalized top-level tags. Default is false until MetaTags 3.0.
44 45 46 |
# File 'lib/meta_tags/configuration.rb', line 44 def resolve_symbolic_references_in_arrays @resolve_symbolic_references_in_arrays end |
#skip_canonical_links_on_noindex ⇒ Boolean
Configure whether MetaTags should skip canonical links on pages with
noindex: true.
John Mueller has noted that mixing noindex and rel=canonical sends
contradictory signals.
https://www.reddit.com/r/TechSEO/comments/8yahdr/2_questions_about_the_canonical_tag/e2dey9i/
55 56 57 |
# File 'lib/meta_tags/configuration.rb', line 55 def skip_canonical_links_on_noindex @skip_canonical_links_on_noindex end |
#title_limit ⇒ Integer?
How many characters to truncate title to.
7 8 9 |
# File 'lib/meta_tags/configuration.rb', line 7 def title_limit @title_limit end |
#title_tag_attributes ⇒ Hash[html_tag_key, html_tag_value]?
HTML attributes for the title tag.
10 11 12 |
# File 'lib/meta_tags/configuration.rb', line 10 def title_tag_attributes @title_tag_attributes end |
#truncate_array_items_at_boundaries ⇒ Boolean
When true, multi-item arrays stop at item boundaries instead of truncating the overflowing item.
20 21 22 |
# File 'lib/meta_tags/configuration.rb', line 20 def truncate_array_items_at_boundaries @truncate_array_items_at_boundaries end |
#truncate_on_natural_separator ⇒ String?, Regexp
A string or regexp separator to truncate text at a natural break.
16 17 18 |
# File 'lib/meta_tags/configuration.rb', line 16 def truncate_on_natural_separator @truncate_on_natural_separator end |
#truncate_site_title_first ⇒ Boolean
Truncate site_title instead of title.
13 14 15 |
# File 'lib/meta_tags/configuration.rb', line 13 def truncate_site_title_first @truncate_site_title_first end |
Instance Method Details
#default_property_tags ⇒ Array<String>
Returns the default meta tag prefixes and names that use property.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/meta_tags/configuration.rb', line 65 def [ # App Links metadata https://developers.facebook.com/docs/applinks/metadata-reference "al", # Open Graph Markup https://developers.facebook.com/docs/sharing/webmasters#markup "fb", "og", # Facebook Open Graph object types https://developers.facebook.com/docs/reference/opengraph # These tags are matched as exact property names or namespace prefixes, so e.g. # 'restaurant' affects 'restaurant:category', 'restaurant:price_rating', and other # properties under that namespace. "article", "book", "books", "business", "fitness", "game", "music", "place", "product", "profile", "restaurant", "video" ].freeze end |
#open_meta_tags? ⇒ Boolean
Indicates whether meta tags should be rendered with open tag syntax.
94 95 96 |
# File 'lib/meta_tags/configuration.rb', line 94 def !! end |
#reset_defaults! ⇒ void
This method returns an undefined value.
Restores the default configuration values.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/meta_tags/configuration.rb', line 101 def reset_defaults! @title_limit = 70 @truncate_site_title_first = false @truncate_on_natural_separator = " " @truncate_array_items_at_boundaries = false @title_tag_attributes = {} @description_limit = 300 @keywords_limit = 255 @keywords_separator = ", " @keywords_lowercase = true @property_tags = .dup @open_meta_tags = true @minify_output = false @resolve_symbolic_references_in_arrays = false @skip_canonical_links_on_noindex = false end |