|
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)