{"id":13405765,"url":"https://github.com/kpumuk/meta-tags","last_synced_at":"2025-05-14T07:08:02.857Z","repository":{"id":432735,"uuid":"53374","full_name":"kpumuk/meta-tags","owner":"kpumuk","description":"Search Engine Optimization (SEO) for Ruby on Rails applications.","archived":false,"fork":false,"pushed_at":"2025-04-21T00:59:08.000Z","size":1017,"stargazers_count":2762,"open_issues_count":18,"forks_count":277,"subscribers_count":48,"default_branch":"main","last_synced_at":"2025-05-07T06:59:24.700Z","etag":null,"topics":["meta-tags","opengraph","opengraph-tags","rails","ruby","search-engine-optimization","seo","seo-meta","seotools","twitter-cards","webmasters"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kpumuk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"MIT-LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2008-09-17T01:41:59.000Z","updated_at":"2025-04-28T15:09:00.000Z","dependencies_parsed_at":"2023-10-10T15:28:28.760Z","dependency_job_id":"70b31ee8-166a-4274-94b5-237cd92fa2d3","html_url":"https://github.com/kpumuk/meta-tags","commit_stats":{"total_commits":510,"total_committers":61,"mean_commits":8.360655737704919,"dds":"0.21372549019607845","last_synced_commit":"0e789071a33ad46c02743f02bf75cffd09735edd"},"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpumuk%2Fmeta-tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpumuk%2Fmeta-tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpumuk%2Fmeta-tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpumuk%2Fmeta-tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kpumuk","download_url":"https://codeload.github.com/kpumuk/meta-tags/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092650,"owners_count":22013290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["meta-tags","opengraph","opengraph-tags","rails","ruby","search-engine-optimization","seo","seo-meta","seotools","twitter-cards","webmasters"],"created_at":"2024-07-30T19:02:10.935Z","updated_at":"2025-05-14T07:08:02.826Z","avatar_url":"https://github.com/kpumuk.png","language":"Ruby","funding_links":[],"categories":["Ruby","View Helper","Web 后端","SEO","视图"],"sub_categories":["Omniauth"],"readme":"# MetaTags: a gem to make your Rails application SEO-friendly\n\n[![Tests](https://github.com/kpumuk/meta-tags/actions/workflows/tests.yml/badge.svg)](https://github.com/kpumuk/meta-tags/actions/workflows/tests.yml)\n[![Gem Version](https://badge.fury.io/rb/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)\n[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)\n[![Code Climate](https://codeclimate.com/github/kpumuk/meta-tags/badges/gpa.svg)](https://codeclimate.com/github/kpumuk/meta-tags)\n[![Test Coverage](https://codeclimate.com/github/kpumuk/meta-tags/badges/coverage.svg)](https://codeclimate.com/github/kpumuk/meta-tags/coverage)\n[![Gem Downloads](https://img.shields.io/gem/dt/meta-tags.svg)](https://badge.fury.io/rb/meta-tags)\n[![Changelog](https://img.shields.io/badge/Changelog-latest-blue.svg)](https://github.com/kpumuk/meta-tags/blob/main/CHANGELOG.md)\n\nSearch Engine Optimization (SEO) plugin for Ruby on Rails applications.\n\n## Ruby on Rails\n\nThe MetaTags main branch fully supports Ruby on Rails 6.1+ and is tested against all major Ruby on Rails releases.\n\n\u003e [!NOTE]\n\u003e 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)).\n\n## Installation\n\nAdd the \"meta-tags\" gem to your `Gemfile`.\n\n```ruby\ngem \"meta-tags\"\n```\n\nAnd run `bundle install` command.\n\n## Configuration\n\nMetaTags 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.\n\nTo override the defaults, create an initializer `config/initializers/meta_tags.rb` using the following command:\n\n```bash\nrails generate meta_tags:install\n```\n\nBy 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.\n\n## MetaTags Usage\n\nFirst, add this code to your main layout:\n\n```erb\n\u003chead\u003e\n  \u003c%= display_meta_tags site: \"My website\" %\u003e\n\u003c/head\u003e\n```\n\nThen, to set the page title, add this to each of your views (see below for other options):\n\n```erb\n\u003ch1\u003e\u003c%= title \"My page title\" %\u003e\u003c/h1\u003e\n```\n\nWhen views are rendered, the page title will be included in the right spots:\n\n```html\n\u003chead\u003e\n  \u003ctitle\u003eMy website | My page title\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003ch1\u003eMy page title\u003c/h1\u003e\n\u003c/body\u003e\n```\n\nYou can find allowed options for the `display_meta_tags` method below.\n\n\u003e [!IMPORTANT]\n\u003e 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.\n\n### Using MetaTags in controller\n\nYou can define the following instance variables:\n\n```ruby\n@page_title = \"Member Login\"\n@page_description = \"Member login page.\"\n@page_keywords = \"Site, Login, Members\"\n```\n\nAlso, you could use the `set_meta_tags` method to define all meta tags simultaneously:\n\n```ruby\nset_meta_tags(\n  title: \"Member Login\",\n  description: \"Member login page.\",\n  keywords: \"Site, Login, Members\"\n)\n```\n\nYou can find the allowed options for the `set_meta_tags` method below.\n\n### Using MetaTags in view\n\nTo set meta tags, you can use the following methods:\n\n```erb\n\u003c% title \"Member Login\" %\u003e\n\u003c% description \"Member login page.\" %\u003e\n\u003c% keywords \"Site, Login, Members\" %\u003e\n\u003c% nofollow %\u003e\n\u003c% noindex %\u003e\n\u003c% refresh 3 %\u003e\n```\n\nAlso, the `set_meta_tags` method exists:\n\n```erb\n\u003c%\n  set_meta_tags(\n    title: \"Member Login\",\n    description: \"Member login page.\",\n    keywords: \"Site, Login, Members\"\n  )\n%\u003e\n```\n\nYou can pass an object that implements the `#to_meta_tags` method and returns a Hash:\n\n```ruby\nclass Document \u003c ApplicationRecord\n  def to_meta_tags\n    {\n      title: title,\n      description: summary\n    }\n  end\nend\n\n@document = Document.first\nset_meta_tags @document\n```\n\nThe `title` method returns the title itself, so you can use it to show the title\nsomewhere on the page:\n\n```erb\n\u003ch1\u003e\u003c%= title \"Member Login\" %\u003e\u003c/h1\u003e\n```\n\nIf you want to set the title and display another text, use this:\n\n```erb\n\u003ch1\u003e\u003c%= title \"Member Login\", \"Here you can login to the site:\" %\u003e\u003c/h1\u003e\n```\n\n### Allowed options for `display_meta_tags` and `set_meta_tags` methods\n\nUse these options to customize the title format:\n\n| Option         | Description                                                                                                         |\n| -------------- | ------------------------------------------------------------------------------------------------------------------- |\n| `:site`        | Site title                                                                                                          |\n| `:title`       | Page title                                                                                                          |\n| `:description` | Page description                                                                                                    |\n| `:keywords`    | Page keywords                                                                                                       |\n| `:charset`     | Page character set                                                                                                  |\n| `:prefix`      | Text between site name and separator                                                                                |\n| `:separator`   | Text used to separate the website name from the page title                                                          |\n| `:suffix`      | Text between separator and page title                                                                               |\n| `:lowercase`   | When true, the page name will be lowercase                                                                          |\n| `:reverse`     | When true, the page and site names will be reversed                                                                 |\n| `:noindex`     | Add noindex meta tag; when true, \"robots\" will be used; accepts a string with a robot name or an array of strings   |\n| `:index`       | Add index meta tag; when true, \"robots\" will be used; accepts a string with a robot name or an array of strings     |\n| `:nofollow`    | Add nofollow meta tag; when true, \"robots\" will be used; accepts a string with a robot name or an array of strings  |\n| `:follow`      | Add follow meta tag; when true, \"robots\" will be used; accepts a string with a robot name or an array of strings    |\n| `:noarchive`   | Add noarchive meta tag; when true, \"robots\" will be used; accepts a string with a robot name or an array of strings |\n| `:canonical`   | Add canonical link tag                                                                                              |\n| `:prev`        | Add prev link tag                                                                                                   |\n| `:next`        | Add next link tag                                                                                                   |\n| `:image_src`   | Add image_src link tag                                                                                              |\n| `:og`          | Add Open Graph tags (Hash)                                                                                          |\n| `:twitter`     | Add Twitter tags (Hash)                                                                                             |\n| `:refresh`     | Refresh interval and optionally URL to redirect to                                                                  |\n\nAnd here are a few examples to give you ideas.\n\n```erb\n\u003c%= display_meta_tags separator: \"\u0026mdash;\".html_safe %\u003e\n\u003c%= display_meta_tags prefix: false, separator: \":\" %\u003e\n\u003c%= display_meta_tags lowercase: true %\u003e\n\u003c%= display_meta_tags reverse: true, prefix: false %\u003e\n\u003c%= display_meta_tags og: { title: \"The Rock\", type: \"video.movie\" } %\u003e\n\u003c%= display_meta_tags alternate: { \"zh-Hant\" =\u003e \"http://example.com.tw/base/url\" } %\u003e\n```\n\n### Allowed values\n\nYou can specify `:title` as a string or array:\n\n```ruby\nset_meta_tags title: [\"part1\", \"part2\"], site: \"site\"\n# site | part1 | part2\nset_meta_tags title: [\"part1\", \"part2\"], reverse: true, site: \"site\"\n# part2 | part1 | site\n```\n\nKeywords can be passed as a string of comma-separated values or as an array:\n\n```ruby\nset_meta_tags keywords: [\"tag1\", \"tag2\"]\n# tag1, tag2\n```\n\nThe description is a string (HTML will be stripped from the output string).\n\n### Mirrored values\n\nSometimes, 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`.\n\nLet's say you have the following code in your application layout:\n\n```ruby\ndisplay_meta_tags og: {\n  title: :title,\n  site_name: :site\n}\n```\n\nThe 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:\n\n```ruby\ntitle \"my great view\"\n```\n\nYou will get this open graph meta tag automatically:\n\n```html\n\u003cmeta property=\"og:title\" content=\"my great view\"\u003e\u003c/meta\u003e\n```\n\n\u003e [!NOTE]\n\u003e The `title` does not include the site name. If you need to reference the exact value rendered in the `\u003ctitle\u003e` meta tag, use `:full_title`.\n\n### Using with Turbo\n\n[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.\n\nIn order to update the page title, you can use the following trick. First, set the ID for the `\u003ctitle\u003e` HTML tag using MetaTags configuration in your initializer `config/initializers/meta_tags.rb`:\n\n```ruby\nMetaTags.configure do |config|\n  config.title_tag_attributes = {id: \"page-title\"}\nend\n```\n\nNow in your turbo frame, you can update the title using a turbo stream:\n\n```html\n\u003cturbo-frame ...\u003e\n  \u003cturbo-stream action=\"update\" target=\"page-title\"\u003e\n    \u003ctemplate\u003eMy new title\u003c/template\u003e\n  \u003c/turbo-stream\u003e\n\u003c/turbo-frame\u003e\n```\n\n### Using with pjax\n\n[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.\n\nMetaTags 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`:\n\n```ruby\ndef default_meta_tags\n  {\n    title: \"Member Login\",\n    description: \"Member login page.\",\n    keywords: \"Site, Login, Members\",\n    separator: \"\u0026mdash;\".html_safe\n  }\nend\n```\n\nThen, in your layout file, use:\n\n```erb\n\u003c%= display_meta_tags(default_meta_tags) %\u003e\n```\n\nAnd in your pjax templates:\n\n```erb\n\u003c!-- set title here so we can use it both in \"display_title\" and in \"title\" --\u003e\n\u003c% title \"My Page title\" %\u003e\n\u003c%= content_tag :div, data: { title: display_title(default_meta_tags) } do %\u003e\n    \u003ch1\u003e\u003c%= title %\u003e\u003c/h1\u003e\n    \u003c!-- HTML goes here --\u003e\n\u003c% end %\u003e\n```\n\n## SEO Basics and MetaTags\n\n### Titles\n\nPage 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.\n\n```ruby\nset_meta_tags title: \"Member Login\"\n# \u003ctitle\u003eMember Login\u003c/title\u003e\nset_meta_tags site: \"Site Title\", title: \"Member Login\"\n# \u003ctitle\u003eSite Title | Member Login\u003c/title\u003e\nset_meta_tags site: \"Site Title\", title: \"Member Login\", reverse: true\n# \u003ctitle\u003eMember Login | Site Title\u003c/title\u003e\n```\n\nRecommended title tag length: up to **70 characters** in **10 words**.\n\nFurther reading:\n\n- [Title Tag](https://moz.com/learn/seo/title-tag)\n\n### Description\n\nDescription 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.\n\nBelow is an example of how to set a description tag using Ruby:\n\n```ruby\nset_meta_tags description: \"This is a sample description\"\n# \u003cmeta name=\"description\" content=\"This is a sample description\"\u003e\n```\n\nIt is advisable to limit the length of the description tag to **300 characters**.\n\nFurther reading:\n\n- [Meta Description](https://moz.com/learn/seo/meta-description)\n- [How Long Should Your Meta Description Be? (2018 Edition)](https://moz.com/blog/how-long-should-your-meta-description-be-2018)\n\n### Keywords\n\nMeta 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).\n\n```ruby\nset_meta_tags keywords: %w[keyword1 keyword2 keyword3]\n# \u003cmeta name=\"keywords\" content=\"keyword1, keyword2, keyword3\"\u003e\n```\n\nIt is recommended to keep the length of the keywords tag under **255 characters** or **20 words**.\n\n\u003e [!NOTE]\n\u003e Both Google and Bing have publicly stated that they completely ignore keywords meta tags.\n\n### Noindex\n\nBy using the noindex meta tag, you can signal to search engines not to include specific pages in their indexes.\n\n```ruby\nset_meta_tags noindex: true\n# \u003cmeta name=\"robots\" content=\"noindex\"\u003e\nset_meta_tags noindex: \"googlebot\"\n# \u003cmeta name=\"googlebot\" content=\"noindex\"\u003e\n```\n\nThis is useful for pages like login, password reset, privacy policy, etc.\n\nFurther reading:\n\n- [Blocking Google](http://www.google.com/support/webmasters/bin/answer.py?hl=en\u0026answer=93708)\n- [Using meta tags to block access to your site](http://www.google.com/support/webmasters/bin/answer.py?hl=en\u0026answer=93710)\n\n### Index\n\nAlthough 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.\n\n```ruby\nset_meta_tags index: true\n# \u003cmeta name=\"robots\" content=\"index\"\u003e\n```\n\n### Nofollow\n\nNofollow 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.\n\n```ruby\nset_meta_tags nofollow: true\n# \u003cmeta name=\"robots\" content=\"nofollow\"\u003e\nset_meta_tags nofollow: \"googlebot\"\n# \u003cmeta name=\"googlebot\" content=\"nofollow\"\u003e\n```\n\nFurther reading:\n\n- [About rel=\"nofollow\"](http://www.google.com/support/webmasters/bin/answer.py?answer=96569)\n- [Meta tags](http://www.google.com/support/webmasters/bin/answer.py?hl=en\u0026answer=79812)\n\n### Follow\n\nYou can use the Noindex meta tag in conjunction with Follow.\n\n```ruby\nset_meta_tags noindex: true, follow: true\n# \u003cmeta name=\"robots\" content=\"noindex, follow\"\u003e\n```\n\nThis 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.\n\n### Canonical URL\n\nCanonical 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.\n\n\u003e [!NOTE]\n\u003e 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.\n\n```ruby\nset_meta_tags canonical: \"http://yoursite.com/canonical/url\"\n# \u003clink rel=\"canonical\" href=\"http://yoursite.com/canonical/url\"\u003e\n```\n\nFurther reading:\n\n- [About rel=\"canonical\"](http://www.google.com/support/webmasters/bin/answer.py?hl=en\u0026answer=139394)\n- [Canonicalization](http://www.google.com/support/webmasters/bin/answer.py?hl=en\u0026answer=139066)\n\n### Icon\n\nA 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.\n\n```ruby\nset_meta_tags icon: \"/favicon.ico\"\n# \u003clink rel=\"icon\" href=\"/favicon.ico\" type=\"image/x-icon\"\u003e\nset_meta_tags icon: \"/favicon.png\", type: \"image/png\"\n# \u003clink rel=\"icon\" href=\"/favicon.png\" type=\"image/png\"\u003e\nset_meta_tags icon: [\n  {href: \"/images/icons/icon_96.png\", sizes: \"32x32 96x96\", type: \"image/png\"},\n  {href: \"/images/icons/icon_itouch_precomp_32.png\", rel: \"apple-touch-icon-precomposed\", sizes: \"32x32\", type: \"image/png\"}\n]\n# \u003clink rel=\"icon\" href=\"/images/icons/icon_96.png\" type=\"image/png\" sizes=\"32x32 96x96\"\u003e\n# \u003clink rel=\"apple-touch-icon-precomposed\" href=\"/images/icons/icon_itouch_precomp_32.png\" type=\"image/png\" sizes=\"32x32\"\u003e\n```\n\nFurther reading:\n\n- [Favicon](https://www.wikiwand.com/en/Favicon)\n- [Touch Icons](https://mathiasbynens.be/notes/touch-icons)\n\n### Multi-regional and multilingual URLs, RSS and mobile links\n\nAlternate link elements tell a search engine when there is content that's translated or targeted to users in a certain region.\n\n```ruby\nset_meta_tags alternate: {\"fr\" =\u003e \"http://yoursite.fr/alternate/url\"}\n# \u003clink rel=\"alternate\" href=\"http://yoursite.fr/alternate/url\" hreflang=\"fr\"\u003e\n\nset_meta_tags alternate: {\"fr\" =\u003e \"http://yoursite.fr/alternate/url\",\n                          \"de\" =\u003e \"http://yoursite.de/alternate/url\"}\n# \u003clink rel=\"alternate\" href=\"http://yoursite.fr/alternate/url\" hreflang=\"fr\"\u003e\n# \u003clink rel=\"alternate\" href=\"http://yoursite.de/alternate/url\" hreflang=\"de\"\u003e\n```\n\nIf you need more than just multi-lingual links, you can use an alternative syntax:\n\n```ruby\nset_meta_tags alternate: [\n  {href: \"http://example.fr/base/url\", hreflang: \"fr\"},\n  {href: \"http://example.com/feed.rss\", type: \"application/rss+xml\", title: \"RSS\"},\n  {href: \"http://m.example.com/page-1\", media: \"only screen and (max-width: 640px)\"}\n]\n```\n\nFurther reading:\n\n- [Multi-regional and multilingual sites](https://support.google.com/webmasters/answer/182192)\n- [About rel=\"alternate\" hreflang=\"x\"](http://www.google.com/support/webmasters/bin/answer.py?hl=en\u0026answer=189077)\n- [Separate URLs](https://developers.google.com/webmasters/mobile-sites/mobile-seo/configurations/separate-urls#annotation-in-the-html)\n\n### Pagination links\n\nPrevious 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.\n\n```ruby\nset_meta_tags prev: \"http://yoursite.com/url?page=1\"\n# \u003clink rel=\"prev\" href=\"http://yoursite.com/url?page=1\"\u003e\nset_meta_tags next: \"http://yoursite.com/url?page=3\"\n# \u003clink rel=\"next\" href=\"http://yoursite.com/url?page=3\"\u003e\n```\n\nFurther reading:\n\n- [Pagination](http://support.google.com/webmasters/bin/answer.py?hl=en\u0026answer=1663744)\n- [Pagination with rel=\"next\" and rel=\"prev\"](http://googlewebmastercentral.blogspot.ca/2011/09/pagination-with-relnext-and-relprev.html)\n\n### image_src links\n\nBasically, 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.\n\n```ruby\nset_meta_tags image_src: \"http://yoursite.com/icons/icon_32.png\"\n# \u003clink rel=\"image_src\" href=\"http://yoursite.com/icons/icon_32.png\"\u003e\n```\n\n### amphtml links\n\nAMP 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:\n\n```ruby\nset_meta_tags amphtml: url_for(format: :amp, only_path: false)\n# \u003clink rel=\"amphtml\" href=\"https://www.example.com/document.amp\"\u003e\n```\n\nTo link back to the normal version, use the `canonical` tag.\n\n- [What Is AMP?](https://www.ampproject.org/learn/about-amp/)\n- [Make Your Page Discoverable](https://www.ampproject.org/docs/guides/discovery)\n\n### Manifest links\n\nBy including the `rel=\"manifest\"` attribute in the `\u003clink\u003e` 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.\n\n```ruby\nset_meta_tags manifest: \"manifest.json\"\n# \u003clink rel=\"manifest\" href=\"manifest.json\"\u003e\n```\n\n- [What is manifest?](https://developer.mozilla.org/en-US/docs/Web/Manifest)\n\n### Refresh interval and redirect URL\n\nMeta 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.\n\n```ruby\nset_meta_tags refresh: 5\n# \u003cmeta content=\"5\" http-equiv=\"refresh\"\u003e\nset_meta_tags refresh: \"5;url=http://example.com\"\n# \u003cmeta content=\"5;url=http://example.com\" http-equiv=\"refresh\"\u003e\n```\n\nFurther reading:\n\n- [Meta refresh](http://en.wikipedia.org/wiki/Meta_refresh)\n- [What is the Meta Refresh Tag](http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm)\n\n### Open Search\n\nOpen Search is a link element used to describe a search engine in a standard and accessible format.\n\n```ruby\nset_meta_tags open_search: {\n  title: \"Open Search\",\n  href: \"/opensearch.xml\"\n}\n# \u003clink href=\"/opensearch.xml\" rel=\"search\" title=\"Open Search\" type=\"application/opensearchdescription+xml\"\u003e\n```\n\nFurther reading:\n\n- [OpenSearch specs](http://www.opensearch.org/Specifications/OpenSearch/1.1)\n- [OpenSearch wiki](http://en.wikipedia.org/wiki/OpenSearch)\n\n### Hashes\n\nAny namespace can be created by simply passing a symbol name and a Hash. For example:\n\n```ruby\nset_meta_tags foo: {\n  bar: \"lorem\",\n  baz: {\n    qux: \"ipsum\"\n  }\n}\n# \u003cmeta property=\"foo:bar\" content=\"lorem\"\u003e\n# \u003cmeta property=\"foo:baz:qux\" content=\"ipsum\"\u003e\n```\n\n### Arrays\n\nRepeated meta tags can be easily created by using an Array within a Hash. For example:\n\n```ruby\nset_meta_tags og: {\n  image: [\"http://example.com/rock.jpg\", \"http://example.com/rock2.jpg\"]\n}\n# \u003cmeta property=\"og:image\" content=\"http://example.com/rock.jpg\"\u003e\n# \u003cmeta property=\"og:image\" content=\"http://example.com/rock2.jpg\"\u003e\n```\n\n### Open Graph\n\nTo turn your web pages into graph objects, you'll need to add Open Graph protocol `\u003cmeta\u003e` 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:\n\n```ruby\nset_meta_tags og: {\n  title: \"The Rock\",\n  type: \"video.movie\",\n  url: \"http://www.imdb.com/title/tt0117500/\",\n  image: \"http://ia.media-imdb.com/rock.jpg\",\n  video: {\n    director: \"http://www.imdb.com/name/nm0000881/\",\n    writer: [\"http://www.imdb.com/name/nm0918711/\", \"http://www.imdb.com/name/nm0177018/\"]\n  }\n}\n# \u003cmeta property=\"og:title\" content=\"The Rock\"\u003e\n# \u003cmeta property=\"og:type\" content=\"video.movie\"\u003e\n# \u003cmeta property=\"og:url\" content=\"http://www.imdb.com/title/tt0117500/\"\u003e\n# \u003cmeta property=\"og:image\" content=\"http://ia.media-imdb.com/rock.jpg\"\u003e\n# \u003cmeta property=\"og:video:director\" content=\"http://www.imdb.com/name/nm0000881/\"\u003e\n# \u003cmeta property=\"og:video:writer\" content=\"http://www.imdb.com/name/nm0918711/\"\u003e\n# \u003cmeta property=\"og:video:writer\" content=\"http://www.imdb.com/name/nm0177018/\"\u003e\n```\n\nMultiple images declared as an **array** (look at the `_` character):\n\n```ruby\nset_meta_tags og: {\n  title: \"Two structured image properties\",\n  type: \"website\",\n  url: \"view-source:http://examples.opengraphprotocol.us/image-array.html\",\n  image: [\n    {\n      _: \"http://examples.opengraphprotocol.us/media/images/75.png\",\n      width: 75,\n      height: 75\n    },\n    {\n      _: \"http://examples.opengraphprotocol.us/media/images/50.png\",\n      width: 50,\n      height: 50\n    }\n  ]\n}\n# \u003cmeta property=\"og:title\" content=\"Two structured image properties\"\u003e\n# \u003cmeta property=\"og:type\" content=\"website\"\u003e\n# \u003cmeta property=\"og:url\" content=\"http://examples.opengraphprotocol.us/image-array.html\"\u003e\n# \u003cmeta property=\"og:image\" content=\"http://examples.opengraphprotocol.us/media/images/75.png\"\u003e\n# \u003cmeta property=\"og:image:width\" content=\"75\"\u003e\n# \u003cmeta property=\"og:image:height\" content=\"75\"\u003e\n# \u003cmeta property=\"og:image\" content=\"http://examples.opengraphprotocol.us/media/images/50.png\"\u003e\n# \u003cmeta property=\"og:image:width\" content=\"50\"\u003e\n# \u003cmeta property=\"og:image:height\" content=\"50\"\u003e\n```\n\nArticle meta tags are supported too:\n\n```ruby\nset_meta_tags article: {\n  published_time: \"2013-09-17T05:59:00+01:00\",\n  modified_time: \"2013-09-16T19:08:47+01:00\",\n  section: \"Article Section\",\n  tag: \"Article Tag\"\n}\n# \u003cmeta property=\"article:published_time\" content=\"2013-09-17T05:59:00+01:00\"\u003e\n# \u003cmeta property=\"article:modified_time\" content=\"2013-09-16T19:08:47+01:00\"\u003e\n# \u003cmeta property=\"article:section\" content=\"Article Section\"\u003e\n# \u003cmeta property=\"article:tag\" content=\"Article Tag\"\u003e\n```\n\nFurther reading:\n\n- [Open Graph protocol](http://developers.facebook.com/docs/opengraph/)\n- [Must-Have Social Meta Tags for Twitter, Google+, Facebook and More](https://moz.com/blog/meta-data-templates-123)\n\n### Twitter Cards\n\nTwitter 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:\n\n```ruby\nset_meta_tags twitter: {\n  card: \"summary\",\n  site: \"@username\"\n}\n# \u003cmeta name=\"twitter:card\" content=\"summary\"\u003e\n# \u003cmeta name=\"twitter:site\" content=\"@username\"\u003e\n```\n\nTake 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.\n\nWhen 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:\n\n```ruby\nset_meta_tags twitter: {\n  card: \"photo\",\n  image: {\n    _: \"http://example.com/1.png\",\n    width: 100,\n    height: 100\n  }\n}\n# \u003cmeta name=\"twitter:card\" content=\"photo\"\u003e\n# \u003cmeta name=\"twitter:image\" content=\"http://example.com/1.png\"\u003e\n# \u003cmeta name=\"twitter:image:width\" content=\"100\"\u003e\n# \u003cmeta name=\"twitter:image:height\" content=\"100\"\u003e\n```\n\nA special parameter `itemprop` can be used on an \"anonymous\" tag \"\\_\" to generate the \"itemprop\" HTML attribute:\n\n```ruby\nset_meta_tags twitter: {\n  card: \"photo\",\n  image: {\n    _: \"http://example.com/1.png\",\n    width: 100,\n    height: 100,\n    itemprop: \"image\"\n  }\n}\n# \u003cmeta name=\"twitter:card\" content=\"photo\"\u003e\n# \u003cmeta name=\"twitter:image\" content=\"http://example.com/1.png\" itemprop=\"image\"\u003e\n# \u003cmeta name=\"twitter:image:width\" content=\"100\"\u003e\n# \u003cmeta name=\"twitter:image:height\" content=\"100\"\u003e\n```\n\nFurther reading:\n\n- [Twitter Cards Documentation](https://dev.twitter.com/cards/)\n\n### App Links\n\nApp Links is an open cross-platform solution for deep linking to content in your mobile app. Here's an example of iOS app integration:\n\n```ruby\nset_meta_tags al: {\n  ios: {\n    url: \"example://applinks\",\n    app_store_id: 12345,\n    app_name: \"Example App\"\n  }\n}\n# \u003cmeta property=\"al:ios:url\" content=\"example://applinks\"\u003e\n# \u003cmeta property=\"al:ios:app_store_id\" content=\"12345\"\u003e\n# \u003cmeta property=\"al:ios:app_name\" content=\"Example App\"\u003e\n```\n\nFurther reading:\n\n- [App Links Documentation](https://developers.facebook.com/docs/applinks)\n\n### Custom meta tags\n\nStarting 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.\n\nExample:\n\n```ruby\nset_meta_tags author: \"Dmytro Shteflyuk\"\n# \u003cmeta name=\"author\" content=\"Dmytro Shteflyuk\"\u003e\n```\n\nYou can also specify the value as an Array, and the values will be displayed as a list of `meta` tags:\n\n```ruby\nset_meta_tags author: [\"Dmytro Shteflyuk\", \"John Doe\"]\n# \u003cmeta name=\"author\" content=\"Dmytro Shteflyuk\"\u003e\n# \u003cmeta name=\"author\" content=\"John Doe\"\u003e\n```\n\n## Maintainers\n\n[Dmytro Shteflyuk](https://github.com/kpumuk), [https://dmytro.sh](https://dmytro.sh)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpumuk%2Fmeta-tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkpumuk%2Fmeta-tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpumuk%2Fmeta-tags/lists"}