Docly Developers
Function Updated 20 Nov 2026

redirect(url, [options])

Stops the page and redirects the browser to the specified url — temporarily (302) or, with { permanent: true }, permanently (301). Works in .hash pages and API functions, and is not swallowed by try/finally in your code.

Parameters

urlstringrequired

Url to redirect browser to.

optionsobjectoptional

{ permanent: true } answers 301 Moved Permanently instead of 302. Leave it out (or pass {}) for 302.

Returns

Nothing — the call ends the request with a Location header. docly.redirect(url) answers 302 Found (a temporary redirect); docly.redirect(url, { permanent: true }) answers 301 Moved Permanently, which search engines treat as a move and pass the old URL's ranking on to the new one. Any other second argument — a status code such as 301, a misspelled option, or permanent that is not true or false — stops the page with an error in the site's console (with the line number), and the visitor gets the site's error page (500). See the KB article "Redirect a moved page with a hash file". (Before 15 October 2026 docly.redirect(url) answered 301.)

Example

Mixed HTML (or any text file) with inline JavaScript between hash signs.
#docly.redirect("https://docly.net")#