diff --git a/Gemfile b/Gemfile index 043b28e..5907b18 100644 --- a/Gemfile +++ b/Gemfile @@ -21,3 +21,6 @@ gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem # do not have a Java counterpart. gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] + +# Add redirects when post urls change +gem 'jekyll-redirect-from' diff --git a/_config.yml b/_config.yml index db8bd77..373784e 100644 --- a/_config.yml +++ b/_config.yml @@ -202,3 +202,6 @@ jekyll-archives: permalinks: tag: /tags/:name/ category: /categories/:name/ + +plugins: + - jekyll-redirect-from diff --git a/_data/authors.yml b/_data/authors.yml index f012012..a4f2fc3 100644 --- a/_data/authors.yml +++ b/_data/authors.yml @@ -11,6 +11,11 @@ cotes: twitter: cotes2020 url: https://github.com/cotes2020/ +thehale: + name: Joseph Hale + github: thehale + url: https://github.com/thehale/ + sille_bille: name: Dinesh Prasanth Moluguwan Krishnamoorthy twitter: dinesh_MKD diff --git a/_posts/2023-11-24-redirects.md b/_posts/2023-11-24-redirects.md new file mode 100644 index 0000000..88b7445 --- /dev/null +++ b/_posts/2023-11-24-redirects.md @@ -0,0 +1,37 @@ +--- +title: "Configuring Redirects" +author: thehale +categories: [Blogging, Tutorial] +tags: [migration] +redirect_from: + - /my/old/url + - /my/other/old/url +--- + + +## Motivation + +When switching to Chirpy from a different Jekyll theme, the URLs of your blog posts might change, breaking backlinks and erasing your SEO gains. + +You'll want to configure redirects so existing bookmarks/links continue working, and so that search engines can find your new URLs and credit them with your SEO history. + +## Configuration + +Simply add the key `redirect_from` to the front matter of your posts. + +```markdown +--- +# ... other front matter keys +redirect_from: + - /my/old/url + - /my/other/old/url +--- + +``` +{: file='2023-11-24-redirects.md' } + +Now the urls [/my/old/url](/my/old/url) and [/my/other/old/url](/my/other/old/url) will forward traffic to the post's new URL with Chirpy. Try them! You'll land back on this article. + +## How it works + +Chirpy includes the plugin [`jekyll-redirect-from`](https://github.com/jekyll/jekyll-redirect-from) which creates a special HTML file at each path listed in the `redirect_from` key in your front matter. That HTML file tells browsers to redirect to the latest link, and it instructs search engines to forward SEO history to the new link.