Hugo - how to override link to content folder html

462 Views Asked by At

We want to use available Hugo themes (like dot) to maintain consistent home page appearance and cross-platform support, but for one content folder we need to directly link to a self-contained html file (i.e. it has <head> and <body> tags, style and script links inside <head>, etc). By "directly" we mean the self-contained html file should display immediately -- yes we can put a link to it inside the content folder index.html, but that's an extra click.

We tried methods on this page. We also tried:

  1. copy necessary info from the self-contained html file's <head> tag into partials/head.html
  2. create a shortcode with {{.Inner}}
  3. in the content folder markdown, after front matter section, use a {{< shortcode_file >}} tag to include all html inside the <body> tag of the self-contained html file

Functionally this works but rendering is bad: the self contained file loads but only a very small part is visible.

Is there a way we can change ("override" ?) the generated link for one content folder to go directly to a static html file, but still keep type=docs formatting/appearance at the top level ?

Update

In layouts/index.html I edited the output like this

 {{ if eq .Title "title of content that needs a direct link" }}
   link to .html file on static folder
 {{ else }}
   link to .Permalink {{/* leave unchanged */}}
 {{ end }}

and that seems to render Ok. I know this is a crude hack and there must be a better way.

0

There are 0 best solutions below