2013-08-10 15:35:34 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
									
										
										
										
											2013-08-17 08:34:25 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								aliases:
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 18:42:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								-  /doc/redirects/ 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  /doc/alias/ 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								-  /doc/aliases/ 
						 
					
						
							
								
									
										
										
										
											2016-01-06 23:45:19 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								lastmod: 2015-12-23
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 18:42:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								date: 2013-07-09
							 
						 
					
						
							
								
									
										
										
										
											2014-04-23 03:00:11 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								menu:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  main:
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 18:42:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parent: extras
							 
						 
					
						
							
								
									
										
										
										
											2016-02-06 10:09:47 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								next: /extras/analytics
							 
						 
					
						
							
								
									
										
										
										
											2014-05-29 18:42:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								prev: /taxonomies/ordering
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Aliases
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								weight: 10
							 
						 
					
						
							
								
									
										
										
										
											2013-08-10 15:35:34 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								For people migrating existing published content to Hugo, there's a good chance you need a mechanism to handle redirecting old URLs.
							 
						 
					
						
							
								
									
										
										
										
											2013-08-10 15:35:34 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Luckily, redirects can be handled easily with _ aliases _  in Hugo.
							 
						 
					
						
							
								
									
										
										
										
											2013-08-10 15:35:34 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Example
  
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-04 12:00:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Given a post on your current Hugo site, with a path of:
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								``content/posts/my-awesome-blog-post.md` `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-04 12:00:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								... you create an "aliases" section in the frontmatter of your post, and add previous paths to that.
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### TOML frontmatter
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-23 09:31:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```toml
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								+++
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ...
							 
						 
					
						
							
								
									
										
										
										
											2015-01-17 00:45:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								aliases = [
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    "/posts/my-original-url/",
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    "/2010/01/01/even-earlier-url.html"
							 
						 
					
						
							
								
									
										
										
										
											2015-01-17 00:45:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								]
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ...
							 
						 
					
						
							
								
									
										
										
										
											2015-01-17 00:45:53 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								+++
							 
						 
					
						
							
								
									
										
										
										
											2015-12-23 09:31:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								### YAML frontmatter
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-23 09:31:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```yaml
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ...
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 19:17:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								aliases:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  /posts/my-original-url/
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    -  /2010/01/01/even-earlier-url.html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ...
							 
						 
					
						
							
								
									
										
										
										
											2015-01-27 19:17:09 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
									
										
										
										
											2015-12-23 09:31:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2013-08-10 15:35:34 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-04 12:00:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Now when you visit any of the locations specified in aliases, _ assuming the same site domain _ , you'll be redirected to the page they are specified on.
							 
						 
					
						
							
								
									
										
										
										
											2013-08-10 15:35:34 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Important Behaviors
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								1.  *Hugo makes no assumptions about aliases. They also don't change based 
						 
					
						
							
								
									
										
										
										
											2015-12-23 09:31:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								on your UglyURLs setting. You need to provide absolute path to your webroot
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								and the complete filename or directory.*
							 
						 
					
						
							
								
									
										
										
										
											2013-08-10 15:35:34 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								2.  *Aliases are rendered prior to any content and will be overwritten by 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								any content with the same location.*
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-16 15:48:42 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## Multilingual example
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								On [multilingual sites ]({{< relref "content/multilingual.md" >}} ), each translation of a post can have unique aliases. To use the same alias across multiple languages, prefix it with the language code.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								In `/posts/my-new-post.es.md` :
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```yaml
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								aliases:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    -  /es/posts/my-original-post/
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								## How Hugo Aliases Work
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-04 12:00:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								When aliases are specified, Hugo creates a physical folder structure to match the alias entry, and, an html file specifying the canonical URL for the page, and a redirect target.
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-08-04 12:00:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Assuming a baseurl of `mysite.tld` , the contents of the html file will look something like:
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-12-23 09:31:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```html
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								<!DOCTYPE html>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								<html>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  <head>
							 
						 
					
						
							
								
									
										
										
										
											2016-03-07 15:05:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    <title>http://mysite.tld/posts/my-original-url</title>
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    <link rel="canonical" href="http://mysite.tld/posts/my-original-url"/>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
							 
						 
					
						
							
								
									
										
										
										
											2016-03-07 15:05:51 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    <meta http-equiv="refresh" content="0; url=http://mysite.tld/posts/my-original-url"/>
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  </head>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</html>
							 
						 
					
						
							
								
									
										
										
										
											2015-12-23 09:31:07 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2015-05-12 15:56:56 +09:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The `http-equiv="refresh"`  line is what performs the redirect, in 0 seconds in this case.