Git Product home page Git Product logo

canonical-url's Introduction

Canonical URL

Canonical URL provides a simple way to utilize the new Canonical URL Standards adopted by all of the major search engines to improve recognition of duplicated URLs. This allows you to represent information in several different places without harming your search engine rank.

Installation

Canonical URL is available both as a gem and as a standard Rails plugin. To install as a gem, add this to your environment.rb:

config.gem 'mbleigh-canonical-url', :source => 'http://gems.github.com'

To install as a traditional plugin:

script/plugin install git://github.com/mbleigh/canonical-url

Usage

The plugin is very simple to use and consists of a controller method and a helper. To set a canonical URL you will first need to add it into your site's layout, like so:

<html>
  <head>
    ...
    <%= canonical_link_tag %>
    ...
  </head>
  ...
</html>

This will automatically insert a canonical URL tag into every page of your site, defaulting to the request's current URL (it will not output anything when you have not specified a canonical URL through the controller or explicitly through the link tag). Then you can set canonical URLs in the controller as follows:

class BlogController < ApplicationController
  def show
    @post = find_post # assume this is a standard blog post type record
    canonical_url blog_post_path(post.year, post.month, post.day, post.slug)
  end
end

Now no matter what the routing is that takes you to the post, the canonical URL will remain the same.

Copyright (c) 2009 Michael Bleigh and Intridea, Inc.. See LICENSE for details.

canonical-url's People

Contributors

brentmc79 avatar otimo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.