Use frontmatter to duplicate a page to multiple output files

Scenario A

If you want to redirect from https://example.org/copy to https://example.org/original, use the aliases field in front matter as suggested by @irkode.

Scenario B

If you want to publish content/original.md to both https://example.org/original and https://example.org/copy, you can use a module mount:

[[module.mounts]]
source = 'content'
target = 'content'

[[module.mounts]]
source = 'content/original.md'
target = 'content/copy.md'

This is impractical if you have more than a few.

Scenario C

Create content/original.md and populate the content. Then create content/copy.md like this:

+++
title = 'Copy'
date = 2024-12-13T00:08:02-08:00
+++

{{% include "/original" %}}

And the “include” shortcode should look like this:

{{ with site.GetPage (.Get 0) }}
  {{ .RenderShortcodes }}
{{ end }}

With this approach you can control the front matter of the copy without having to duplicate the content.

Symbolic links

Support for symbolic links, also known as soft links or junctions, was removed in v0.123.0.

3 Likes