-
-
Save schadenfred/dd2b2f56f7c4ca6fcc81b2dd8c015c2e to your computer and use it in GitHub Desktop.
meta-tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
$ bundle add meta-tags | |
``` | |
in config/locales/en.yml | |
``` | |
en: | |
metatags: &metatags | |
canonical: handsomefencer.club | |
canonical: "#{params}" | |
charset: utf-8 | |
description: Navy SEALs I Have Met in Hollywood | |
keywords: | |
- foo | |
- bar | |
site: StarBangers | |
title: Memoir Writing Site for Navy Special Warfare | |
viewport: width=device-width,initial-scale=1 | |
index: true | |
static_pages: | |
home: | |
tags: &tags | |
title: Override title here | |
metatags: | |
<<: *metatags ## base metatags | |
<<: *tags ## override with visible tags above | |
noindex: true ## override visible tags with metatags here. | |
``` | |
in app/componnts/meta_tags_component: | |
``` | |
# frozen_string_literal: true | |
class MetaTagsComponent < ApplicationComponent | |
def initialize(params:, author:, record:, canonical:) | |
I18n.t("#{params['controller']}.#{params['action']}.metatags") | |
end | |
end | |
``` | |
in app/componnts/meta_tags_component/meta_tags_component.html.erb: | |
``` | |
<%= display_meta_tags @metatags %> | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment