Git Product home page Git Product logo

rails_will_paginate_seo_helper's Introduction

rails_will_paginate_seo_helper

This is standing on the shoulder of a giant: ❤️ https://github.com/mislav/will_paginate and adds some seo-sugar on top.

A simple Rails ViewHelper to display link-tags for will_paginate in header.

Url-Parameter left untouched.

Atm. expects 'page' as page_param -key.

Google suggests to add rel=next and rel=prev link-tags on paged pages: https://webmasters.googleblog.com/2011/09/pagination-with-relnext-and-relprev.html

If you want to have seo link-tags for pages in your rails app without monkey patching will_paginate:

Setup

simple add to your Gemfile:

 # works with rails 4 and 5
 gem 'will_paginate'
 gem 'rails_will_paginate_seo_helper'

Usage

a will_paginate paged ActiveRecord::Relation from your controller:

@todos = Todo.all.paginate(page: params[:page])

now you can use on your templates (expects <%= yield :pagination_rel_links %> in the header section of your layout)

 <!-- in todos/index.html.erb -->
 <% content_for :pagination_rel_links do %>
  <!-- this will showup in the header section of your html -->
  <%= will_paginate_seo_links(@todos) %>
 <% end %>

given we are on page 2 - output will be:

<link href="http://localhost:3000/todos" rel="prev">
<link href="http://localhost:3000/todos?page=3" rel="next">

rails_will_paginate_seo_helper's People

Contributors

erpe avatar lennart avatar kantyka avatar rafallo avatar wielinde avatar

Watchers

James Cloos 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.