Skip to main content
  • Middleman Home page
  • Support
  • Community
  • Documentation

Basics

  • Install
  • Upgrading to v4
  • Start a New Site
  • Directory Structure
  • Development Cycle
  • Build & Deploy
  • Frontmatter
  • Templating Language
  • Helper Methods
  • Layouts
  • Partials
  • Redirects
  • Blogging

Advanced

  • Configuring Your Site
  • Project Templates
  • Dynamic Pages
  • Data Files
  • Localization (i18n)
  • Asset Pipeline
  • External Pipeline
  • Rack Middleware
  • The Sitemap
  • Pretty URLs (Directory Indexes)
  • Improving Cacheability
  • File Size Optimization
  • Custom Extensions
  • Template Engine Options

Redirects

Some times you need to change a file path, but maintain the old URLs for bookmarked users and search engines. For SEO reasons, it is recommended that you configure your webserver to send a "301 Redirect" header to point your visitors to the new location of the content.

However, in some cases, you will not have access to the server to add this feature. Middleman can generate HTML files which will redirect your visitors, but, these old paths are likely to still appear in search engines and will negatively impact your SEO.

To generate a redirect in Middleman, add the following to config.rb:

redirect "my/old/path.html", to: "/my/new/path.html"

The old path should not have a leading slash and should refer to a file such as path/index.html, not just a path.

© 2011–2022 Thomas Reynolds

Maintained by the core team with help from contributors.

  • Twitter
  • GitHub