Home / Function/ redirectTemplate() — astro Function Reference

redirectTemplate() — astro Function Reference

Architecture documentation for the redirectTemplate() function in 3xx.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  64504505_86b0_c830_3f87_535fdcfe02dc["redirectTemplate()"]
  cb5d9762_9457_175c_2a1c_8ca8ed659aa6["3xx.ts"]
  64504505_86b0_c830_3f87_535fdcfe02dc -->|defined in| cb5d9762_9457_175c_2a1c_8ca8ed659aa6
  style 64504505_86b0_c830_3f87_535fdcfe02dc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/routing/3xx.ts lines 8–25

export function redirectTemplate({
	status,
	absoluteLocation,
	relativeLocation,
	from,
}: RedirectTemplate) {
	// A short delay causes Google to interpret the redirect as temporary.
	// https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh
	const delay = status === 302 ? 2 : 0;
	return `<!doctype html>
<title>Redirecting to: ${relativeLocation}</title>
<meta http-equiv="refresh" content="${delay};url=${relativeLocation}">
<meta name="robots" content="noindex">
<link rel="canonical" href="${absoluteLocation}">
<body>
	<a href="${relativeLocation}">Redirecting ${from ? `from <code>${from}</code> ` : ''}to <code>${relativeLocation}</code></a>
</body>`;
}

Domain

Subdomains

Frequently Asked Questions

What does redirectTemplate() do?
redirectTemplate() is a function in the astro codebase, defined in packages/astro/src/core/routing/3xx.ts.
Where is redirectTemplate() defined?
redirectTemplate() is defined in packages/astro/src/core/routing/3xx.ts at line 8.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free