{"id":25770852,"url":"https://github.com/borfast/jekyll-server-redirects","last_synced_at":"2025-02-27T02:38:39.684Z","repository":{"id":56878798,"uuid":"56890912","full_name":"borfast/jekyll-server-redirects","owner":"borfast","description":"A Jekyll plugin to generate server-side redirects","archived":false,"fork":false,"pushed_at":"2017-01-28T16:10:22.000Z","size":5,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-25T03:01:57.594Z","etag":null,"topics":["jekyll","jekyll-plugin","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/borfast.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-22T23:34:43.000Z","updated_at":"2018-02-13T17:47:36.000Z","dependencies_parsed_at":"2022-08-20T22:30:57.962Z","dependency_job_id":null,"html_url":"https://github.com/borfast/jekyll-server-redirects","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borfast%2Fjekyll-server-redirects","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borfast%2Fjekyll-server-redirects/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borfast%2Fjekyll-server-redirects/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borfast%2Fjekyll-server-redirects/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borfast","download_url":"https://codeload.github.com/borfast/jekyll-server-redirects/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240967291,"owners_count":19886215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jekyll","jekyll-plugin","ruby"],"created_at":"2025-02-27T02:38:39.062Z","updated_at":"2025-02-27T02:38:39.677Z","avatar_url":"https://github.com/borfast.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jekyll::ServerRedirects\n\nThis was written because I wanted to migrate my blog from Drupal to Jekyll and I wanted to keep the old URLs.\n\nMost people who use Jekyll seem to prefer to generate HTML pages with a meta refresh tag in them to redirect the browser.\nI wanted to do it via the server, so I could have proper 301 redirects and not have to keep a few hundred unwanted files lying around.\n\nThere is a Jekyll plugin, [Jekyll::NginxConfig](https://github.com/activelamp/jekyll-nginx-config) that is supposed to do this but for some reason it wasn't working. I also tried other plugins like [Jekyll Pageless Redirects](https://github.com/nquinlan/jekyll-pageless-redirects), [Alias Generator for Posts](https://github.com/tsmango/jekyll_alias_generator) and [JekyllRedirectFrom](https://github.com/jekyll/jekyll-redirect-from), which seemed like the most promising one, but I could get none of them working.\n\nThis was driving me insane, so I grabbed Jekyll::NginxConfig and changed it to do what I wanted. While I was at it, I figured I could add the ability to generate redirects for Apache and not just nginx.\n\n### Installation\n\nAdd this to your `Gemfile`:\n\n```ruby\ngroup :jekyll_plugins do\n  gem 'jekyll-server-redirects'\nend\n```\n\n\u003e You have to specify it under the `:jekyll_plugins` group otherwise Jekyll won't recognize the `server_redirects` command.\n\nThen run `bundle install`.\n\n\u003e If using a global Jekyll installation, just do `gem install jekyll-server-redirects`\n\n### Basic usage\n\nOn each post you want to redirect to from another URL, add the following to the front matter:\n\n```yaml\n:redirect_from:\n  - blog/old-url\n  - node/641\n```\nThis block lists the URLs you want to redirect to your new URL from.\n\nAfter having all the posts configured, run the following command to generate the server configuration:\n\n```bash\nbundle exec jekyll server_redirects --server_type nginx\n```\n\n\u003e If you didn't install the plugin with Bundler, drop the `bundle exec` part of the command.\n\n\u003e If you want to use Apache instead of nginx, just replace `nginx` with `apache` in the command.\n\nThis will output the list of redirects for your server of choice. If you want to store it directly in a file, you can append ` \u003e redirects.conf` to the command.\n\n### Custom redirects\n\nIf you want some custom redirects, you can do so easily by adding a few lines to your Jekyll config file (typically `_config.yml`):\n\n```yaml\ncustom_redirects:\n  - from: ^/old-url$\n    to: /blog/new-url\n    type: permanent\n\n  - from: ^/another-old-url$\n    to: /under-construction\n    type: temp\n```\n\nItems under `custom_redirects` are simply translated straight into server directives. In this case and assuming nginx:\n\n```nginx\nrewrite ^/old-url$ /blog/new-url permanent;\nrewrite ^/another-old-url$ /under-construction temp;\n```\n\nTo know more, [see documentation about Nginx's `rewrite` directives](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html)\n\n#### Custom server directives template\n\nYou can also specify your own Liquid template file to use if you wish to have complete control on the resulting server redirection directives. Use `--config_template \u003cPATH TO LIQUID TEMPLATE\u003e`.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborfast%2Fjekyll-server-redirects","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborfast%2Fjekyll-server-redirects","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborfast%2Fjekyll-server-redirects/lists"}