GenerateRedirects Class
Handles redirected content by creating pages with meta refresh tags or other redirect files.
Namespace
Statiq.Core
Interfaces
Base Types
graph BT Type-->Base0["Module"] click Base0 "/api/Statiq.Common/Module" Base0-->Base1["object"] Type-.->Interface0["IModule"] click Interface0 "/api/Statiq.Common/IModule" Type["GenerateRedirects"] class Type type-node

Syntax

public class GenerateRedirects : Module, IModule

Remarks

When content moves you need some way to redirect from the old location to the new location. This is especially true when moving content from one publishing system to another that might have different conventions for things like paths.

This module lets you manage redirected content by generating special pages that contain a "meta refresh tag". This tag tells client browsers that the content has moved and to redirect to the new location. Google and other search engines also understand meta refresh tags and will adjust their search indexes accordingly.

Alternatively (or additionally), you can also create host-specific redirect files to control redirection on the server.

By default, this module will read the paths that need to be redirected from the RedirectFrom metadata key. One or more paths can be specified in this metadata and corresponding redirect files will be created for each.

This module outputs any meta refresh pages as well as any additional redirect files you specify. It does not output the original input files.

Methods

Name Return Value Summary
AfterExecution(IExecutionContext, ExecutionOutputs) void
Called after each module execution.
Inherited from Module
AfterExecutionAsync(IExecutionContext, ExecutionOutputs) Task
Called after each module execution.
Inherited from Module
AlwaysCreateAdditionalOutput(bool) GenerateRedirects
Always creates any additional output documents even if there are no redirected paths.
BeforeExecution(IExecutionContext) void
Called before each module execution.
Inherited from Module
BeforeExecutionAsync(IExecutionContext) Task
Called before each module execution.
Inherited from Module
ExecuteAsync(IExecutionContext) Task<IEnumerable<IDocument>>
This should not be called directly, instead call IExecutionContext.Execute() if you need to execute a module from within another module.
Inherited from Module
ExecuteContextAsync(IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module once for all input documents.
ExecuteInputAsync(IDocument, IExecutionContext) Task<IEnumerable<IDocument>>
Executes the module.
Inherited from Module
Finally(IExecutionContext) void
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
FinallyAsync(IExecutionContext) Task
Called after each module execution, even if an exception is thrown during execution.
Inherited from Module
IncludeHost(bool) GenerateRedirects
Indicates whether the host should be automatically included in generated redirect links.
WithAdditionalOutput(NormalizedPath, Func<IDictionary<NormalizedPath, string>, IExecutionContext, string>) GenerateRedirects
Adds additional output files that you specify by supplying a delegate that takes a dictionary of redirected paths to destination URLs.
WithAdditionalOutput(NormalizedPath, Func<IDictionary<NormalizedPath, string>, IExecutionContext, Task<string>>) GenerateRedirects
Adds additional output files that you specify by supplying a delegate that takes a dictionary of redirected paths to destination URLs.
WithAdditionalOutput(NormalizedPath, Func<IDictionary<NormalizedPath, string>, string>) GenerateRedirects
Adds additional output files that you specify by supplying a delegate that takes a dictionary of redirected paths to destination URLs.
WithAdditionalOutput(NormalizedPath, Func<IDictionary<NormalizedPath, string>, Task<string>>) GenerateRedirects
Adds additional output files that you specify by supplying a delegate that takes a dictionary of redirected paths to destination URLs.
WithMetaRefreshPages(bool) GenerateRedirects
Controls whether meta refresh pages are output.
WithPaths(Config<IReadOnlyList<NormalizedPath>>) GenerateRedirects
Controls where the redirected paths come from. By default, values from the metadata key RedirectFrom are used.

Extension Methods