Skip to content
Quick and configurable canonical tag to use in Rails views.
Ruby HTML JavaScript CSS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app/helpers
config Generated a Rails engine Apr 2, 2012
gemfiles
lib Patch version bump Jun 25, 2019
script
spec Recover spcs Feb 1, 2018
.gitignore setup appraisal May 25, 2016
.rspec
.travis.yml Lock bundler to 1.x for older Ruby runtimes Jan 19, 2019
Appraisals
Gemfile Generated a Rails engine Apr 2, 2012
MIT-LICENSE Generated a Rails engine Apr 2, 2012
README.md Remove outdated badge Aug 7, 2018
Rakefile Generated a Rails engine Apr 2, 2012
canonical-rails.gemspec Add Rails 6.0 support Jan 19, 2019

README.md

CanonicalRails

Build Status

A number of articles exist explaining the issue concisely and at length:

Guide

Take a look at this blog post that can guide you through the idea and the setup: Easily add canonical URLs to your Rails app

Challenge

I've seen a lot of folks do more harm by neglecting canonicalization altogether than by applying too narrowly and conservatively, so here is an attempt to let people start modestly without spending too much time on it and whitelist parameters as they need to.

Install

gem 'canonical-rails', github: 'jumph4x/canonical-rails'

Usage

First, generate the config

rails g canonical_rails:install

Then find it in config/initializers/ as canonical_rails.rb

Finally, include the canonical_tag helper inside the head portion of your HTML views:

  <%= canonical_tag -%>

Cred

A project by Downshift Labs, Ruby on Rails, Performance tuning and Spree Commerce projects.

You can’t perform that action at this time.