Skip to content

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.

License

Notifications You must be signed in to change notification settings

marquesaline/jekyll-server-side-redirects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages