Docly Developers
DocsUpdated 20 Nov 2026

Redirect to a page or site

Redirect from a hash page with docly.redirect(url) - temporarily (302) or permanently (301) - and how to make a redirect site.

docly.redirect(url)

#docly.redirect("https://www.google.com")#
#docly.redirect("https://www.google.com", { permanent: true })#

docly.redirect(url) answers 302 Found - a temporary redirect. For a page or site that has moved for good, add { permanent: true }: it answers 301 Moved Permanently.

The second argument is an options object, not a status code: docly.redirect(url, 301) is an error in the site's console, and the visitor gets the site's error page. See Redirect a moved page with a hash file.

Create a redirect site

Follow this example to redirect requests (with or without www) www.domain.com to domain.com. Or other domain.

Create a site and make ONLY a "#/404.hash" handler that catches all requests and redirects them to the other site:

>

#/404.hash

#{
    docly.redirect("https://other-domain.com" + request.url, { permanent: true });
}#

Note that request.url always starts with / and holds the path from the published site root. The redirect is a 301 (permanent), since a site that has moved to another domain usually stays there. Leave out { permanent: true } for a 302 (temporary).