How to render a set of HTML files directly?

Hi,

I have a set of HTML files. There are generated by asciidoctor.

I would like to use Hugo to make a website with them with gitlab pages. Asciidoctor is not installed on the server I use and I can’t have it installed.

I have read on another discussion that : “The trick here is to add frontmatter. Even just the empty start and end of a front matter will do.”

What do I have to add exactly and where ?

My HTML file are “normal” ones, beginning with something like :

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 1.5.5">
etc..

Thanks

By start and end of frontmatter, it means adding 2 lines with --- or +++ which normally delimit frontmatter in a markdown file.:

---
---
<!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset="UTF-8">
    <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="Asciidoctor 1.5.5">
    etc..
2 Likes

Hello Rick,

Thanks for your answer. I have another problem related to this:

I have a page of “…/careers/”. And I use a career platform for my page. So I managed to call the platform’s api and get all jobs on /careers/.

Now, my goal is to direct users to careers details page when they click on each job.

Say I have job of id#1, job of id #2, etc from API. But I don’t want to store job1.md, job2.md, etc for all jobs in content folder. How can I skip using a md file and directly use my layout/careers/single.html?

I’ve red a lot of Hugo posts and docs but have no clue how to implement it as almost everyone says something like this is impossible.

Please let me know if you have ideas. Really appreciate it.

Jen

If those job detail pages exist at some URL, and you can get the URLs via your data download, you can parse the data (for instance if it is json), and list the jobs and their URLs. But generating pages automatically from data is not yet possible. You could make a shortcode that pulls from your data, though, so that making a jobN.md file is trivial, just call the shortcode specifying a job number…

Thanks Rick! Just a further question: for front matter, is below code possible to work?

Option 1 – dynamic title in front matter file:

In config.toml:

.......(other code)......
[permalinks]
        careers = "/careers/:title/"
.......(other code)......

In /content/careers/default.md:

...
type: "careers"
title: "{{ $jobID }}"
...
{{ $gistJ := getJSON "MY_URL_TO_GET_ALL_JOBS_WITH_IDS" }}
{{ range $gistJ.data }}
{{ $jobID := .id }}

Or:

...
type: "careers"
title: "[1, 2, 3, ..., 20]" (some sort of array of all job ids)
...

Option 2 – workaround with shortcode and not having permalinks in config:

In config.toml:

.......(other code)......
(no specified permalinks for careers)
.......(other code)......

In /content/careers/default.md:

...
type: "careers"
...
<!DOCTYPE html> 
<html lang="en"> 
      <head> 
      <meta charset="UTF-8> 
      etc..

The detailed logic above may not be accurate but would like to know if those directions are possible. I’ve been searched for LOTS of Hugo articles, blogs, and discussions but no luck. So plz let me know if there is a solution that I miss.

I appreciate it.
Jen

Hi, this topic is veering away from the OPs purpose so I will close it, and, could you please create a new post? Also, we need some more info to be able to help you, so please have a look at Requesting Help and provide some more details? A git repository with what you are trying would be helpful, especially. Thanks.

This topic was automatically closed after 31 minutes. New replies are no longer allowed.