Handles redirected content by creating pages with meta refresh tags or other redirect files.

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.


  • Redirect()

Fluent Methods

Chain these methods together after the constructor to modify behavior.

  • IncludeHost(bool includeHost = true)

    Indicates whether the host should be automatically included in generated redirect links.

    • includeHost

      true to include the host.

  • WithAdditionalOutput(FilePath path, Func<IDictionary<FilePath, string>, string> content)

    Adds additional output files that you specify by supplying a delegate that takes a dictionary of redirected paths to destination URLs.

    • path

      The path of the output file (must be relative).

    • content

      A delegate that takes a dictionary with keys equal to each redirected file and values equal to the destination URL. The delegate should return the content of the output file.

  • WithMetaRefreshPages(bool metaRefreshPages = true)

    Controls whether meta refresh pages are output.

    • metaRefreshPages

      If true, meta refresh pages are generated.

  • WithPaths(DocumentConfig paths)

    Controls where the redirected paths come from. By default, values from the metadata key RedirectFrom are used.

    • paths

      A delegate that should return one or more Wyam.Common.IO.FilePath.

Input Metadata

The metadata values listed below apply to individual documents and are typically set from front matter (with just the name of the key) and used as inputs to the module to control behavior.

  • Keys.RedirectFrom: Wyam.Common.IO.FilePath

    The path(s) where the document should be redirected from.

Output Metadata

The metadata values listed below apply to individual documents and are created and set by the module as indicated in their descriptions.

  • Keys.RelativeFilePath: Wyam.Common.IO.FilePath

    The path to the file relative to the input folder. This metadata value is used when generating links to the document.

  • Keys.WritePath: Wyam.Common.IO.FilePath

    The path to use when writing the file.