Skip to content
Home button
  • Pricing
Skip to content

Routing

On this page:

Loading...

Easy routing configuration to configure redirects, 404 pages, and customize URLs.

301 redirects

When you change your website’s structure, you should redirect the old URLs to the new pages. This ensures external links pointing to the old content and search engines can be redirected.

To set up 301 redirects:

  1. Create a file called 301.txt at the root of your site
  2. Specify the redirects in this file using the following syntax

old-url new-url

You can also redirect to external domains and wildcard matching with *. Here’s an example file:

301.txt
/about.html /about/
/category/* /new-category
/should-have-been-elsewhere/ https://example.com

Redirects will only occur if the redirect-from page/location no longer exists within the site. If the page/location still exists within your site, this will be served instead of performing a redirect.

Note

You can redirect to, but not from a URL fragment (e.g. #example-heading). The fragment is not passed to the server so, it cannot be processed by the redirect.

404 Page

CloudCannon serves a 404 page when it can’t find a file on your site. Create your own 404 page to blend in with the rest of your site.

To create a custom 404 page:

  1. Create a file called 404.html at the root of your site
  2. Add the content you want CloudCannon to serve
Note

Set the permalink of your page to /404.html if you are using Jekyll and non-default permalinks.

Extensionless URLs

Extensionless URLs do not end with a trailing slash or a file extension. They map to the file in the same path with an html, htm or xml extension. For example, these URLs would serve the same file:

https://example.com/about
https://example.com/about.html

To serve files on extensionless URLs:

  1. Go to Site Settings / Routing
  2. Enable Serve Extensionless URLs and optionally Force Extensionless URLs
  3. Click Update Hosting Details
Note

Serve Extensionless URLs is on by default for new sites for compatibility with the latest Jekyll versions.

Enabling Force Extensionless URLs redirects URLs with html, htm or xml extensions to extensionless versions. This ensures a single URL rather than serving the same file on two different URLs.

CloudCannon automatically adds the cc-active class to any <a> tags that point to the current page. Style the cc-active class with CSS to highlight it.

styles.css
.cc-active {
  opacity: 0.5;
  pointer-events: none;
}
On this page:

Loading...

Don’t miss the latest
CloudCannon news freshly delivered to your inbox
Illustration of woman holding an envilope