The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Fixing a little anchor permalinks vs. pagination issue (using javascript and jekyll)

0 replies.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a flat view of this topic  Flat View
Previous Topic   Next Topic
Threaded View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
Fixing a little anchor permalinks vs. pagination issue (using javascript and jekyll) Posted: Dec 5, 2011 9:40 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jan Lelis.
Original Post: Fixing a little anchor permalinks vs. pagination issue (using javascript and jekyll)
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;). So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

I am using the Jekyll blog generator for some projects (still not sure if I really like it..) and came across the following requirement the other day:

  • The blog should only have an index page, no (visible) sub-posts
  • This index page should use pagination
  • There should be the ability to link to a specific blog post

The problem was: I wanted to use anchor links (http://some.url/#post-identifier), but – because of the pagination – blog posts “change” their index page (e.g. in jekyll, they move from /#example to /page2/#example).

I decided to fix this using this small piece of JavaScript code. If the blog post is not found on the current page, it will redirect the user to the correct page. Nothing special, but why not share? ;)

See this permalink for an example in action (you will be redirected to page 2). The code might easily be adopted for other blogging engines.

CC-BY (DE)

Read: Fixing a little anchor permalinks vs. pagination issue (using javascript and jekyll)


Topic: Fixing a little anchor permalinks vs. pagination issue (using javascript and jekyll) Previous Topic   Next Topic Topic: Why you should switch to 1.9: Three Ruby 1.8 bugs

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use