Redirect blog post to an external URL or an `.html` in the site

I’d like to create a post content/posts/ that is shown in my list of posts but that redirects to an external URL or another .html in static when folks click the link in my list of posts.

aliases is not the answer, since that is for when I want other other pages to redirect to THIS. (the inverse)

I was thinking to create a new optional front matter for my posts.

title: dynamic models
date: 2019-03-22
    - chemical engineering

seem like a good approach? but then when I modify my list of posts in the cactus theme here to:

    {{ if .RedirectURL }}
        <a class="" href="{{ .RedirectURL }}">{{ if .Title }} {{ .Title }} {{ else }} Untitled {{ end }}</a>
      {{ else }}
        <a class="" href="{{ .Permalink }}">{{ if .Title }} {{ .Title }} {{ else }} Untitled {{ end }}</a>
      {{ end }}

I get an error can’t evaluate field RedirectURL in type page.Page render of "term" failed. I’ve tried with too. any idea how I can make this work?

esp open to ways to doing this without modifying the theme…

First, to access a custom field in front matter you need to do:

{{ .Params.redirectURL }}

Second, this sounds a bit like “cloaked” or “affiliate” links, so this might be useful: