2014-01-03 23:36:53 +00:00
---
aliases:
2014-05-29 22:42:05 +00:00
- /doc/urls/
2016-01-06 22:45:19 +00:00
lastmod: 2015-12-08
2014-05-29 22:42:05 +00:00
date: 2014-01-03
2014-04-23 07:00:11 +00:00
menu:
main:
2014-05-29 22:42:05 +00:00
parent: extras
2015-12-08 21:13:09 +00:00
next: /extras/robots-txt
2014-05-29 22:42:05 +00:00
notoc: true
prev: /extras/toc
title: URLs
2014-11-25 08:07:18 +00:00
weight: 110
2014-01-03 23:36:53 +00:00
---
2014-02-21 00:04:29 +00:00
2014-08-31 11:08:36 +00:00
## Pretty URLs
2014-02-21 00:04:29 +00:00
2015-09-02 19:22:21 +00:00
By default, Hugo creates content with 'pretty' URLs. For example,
2015-01-23 01:04:07 +00:00
content created at `/content/extras/urls.md` will be rendered at
`/public/extras/urls/index.html` , thus accessible from the browser
at http://example.com/extras/urls/. No non-standard server-side
configuration is required for these pretty URLs to work.
2014-02-21 00:04:29 +00:00
2015-01-23 01:04:07 +00:00
If you would like to have what we call "ugly URLs",
e.g. http://example.com/extras/urls.html, you are in luck.
Hugo supports the ability to create your entire site with ugly URLs.
Simply add `uglyurls = true` to your site-wide `config.toml` ,
2015-09-09 05:29:04 +00:00
or use the `--uglyURLs=true` flag on the command line.
2014-02-21 00:04:29 +00:00
2014-08-31 11:08:36 +00:00
If you want a specific piece of content to have an exact URL, you can
2015-01-23 01:04:07 +00:00
specify this in the front matter under the `url` key. See [Content
2015-08-04 18:00:08 +00:00
Organization](/content/organization/) for more details.
2014-02-21 00:04:29 +00:00
## Canonicalization
2015-01-23 01:04:07 +00:00
By default, all relative URLs encountered in the input are left unmodified,
2015-02-21 21:46:12 +00:00
e.g. `/css/foo.css` would stay as `/css/foo.css` ,
i.e. `canonifyurls` defaults to `false` .
2015-01-23 01:04:07 +00:00
By setting `canonifyurls` to `true` , all relative URLs would instead
be *canonicalized* using `baseurl` . For example, assuming you have
`baseurl = http://yoursite.example.com/` defined in the site-wide
2015-02-21 21:46:12 +00:00
`config.toml` , the relative URL `/css/foo.css` would be turned into
2015-01-23 01:04:07 +00:00
the absolute URL `http://yoursite.example.com/css/foo.css` .
2014-01-03 23:36:53 +00:00
Benefits of canonicalization include fixing all URLs to be absolute, which may
aid with some parsing tasks. Note though that all real browsers handle this
client-side without issues.
Benefits of non-canonicalization include being able to have resource inclusion
be scheme-relative, so that http vs https can be decided based on how this
page was retrieved.
2015-01-23 01:04:07 +00:00
2015-02-21 21:46:12 +00:00
> Note: In the May 2014 release of Hugo v0.11, the default value of `canonifyurls` was switched from `true` to `false`, which we think is the better default and should continue to be the case going forward. So, please verify and adjust your website accordingly if you are upgrading from v0.10 or older versions.
2015-01-23 01:04:07 +00:00
2015-02-21 21:46:12 +00:00
To find out the current value of `canonifyurls` for your website, you may use the handy `hugo config` command added in v0.13:
2015-01-23 01:04:07 +00:00
2015-02-21 21:46:12 +00:00
hugo config | grep -i canon
2015-01-23 01:04:07 +00:00
2015-02-21 21:46:12 +00:00
Or, if you are on Windows and do not have `grep` installed:
2015-01-23 01:04:07 +00:00
2015-02-21 21:46:12 +00:00
hugo config | FINDSTR /I canon
2015-01-23 01:04:07 +00:00