No release in over a year
Generates server-specific files for handling redirects (e.g., .htaccess, firebase.json).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.13
 Project Readme

Jekyll Server-Side Redirects

A Jekyll plugin that generates server-specific redirection files (e.g., .htaccess or firebase.json) to improve SEO by allowing you to create server-side redirects with appropriate HTTP status codes.

Features

  • Server Support: Generate redirect configuration for:
    • Firebase Hosting (firebase.json)
    • Apache (.htaccess)
  • SEO Optimization: Properly inform search engines about page moves using HTTP status codes.
  • Jekyll Integration: Define redirects directly in your Jekyll pages and posts using redirect_from in the frontmatter.

Installation

As a Ruby Gem

  1. Add the gem to your Gemfile:

    gem 'jekyll-server-side-redirects'
  2. Run bundle install to install the gem.

Manually

If you're not using Bundler, you can install the gem manually:

gem install jekyll-server-side-redirects

Then, add it to your _config.yml file:

plugins:
  - jekyll-server-side-redirects

Configuration

Add the following configuration to your _config.yml file:

server_redirects:
  server: 'apache' # Options: 'firebase', 'apache'

Usage

Add Redirects in Frontmatter

Define redirects in the redirect_from frontmatter field for your pages or posts:

---
title: "My New Page"
redirect_from:
  - /old-page1/
  - /another-old-page/
redirect_type: 302 # Optional: Defaults to 301 (permanent redirect)
---

Build Your Jekyll Site

When you build your site, the plugin will automatically generate the appropriate redirection file based on the configured server:

For Firebase, a firebase.json file will be created or updated. For Apache, a .htaccess file will be created or updated.

Examples

Firebase

A firebase.json file will be generated as follows:

{
  "hosting": {
    "redirects": [
      { "source": "/old-page1/", "destination": "/new-page1/", "type": 301 },
      { "source": "/old-page2/", "destination": "/new-page2/", "type": 302 }
    ]
  }
}

Apache

A .htaccess file will be generated as follows:

# .htaccess file generated by Jekyll Server-Side Redirects

Redirect 301 /old-page1/ /new-page1/
Redirect 302 /old-page2/ /new-page2/