Add raw html page as post

I am using Academic theme. I wish to put some raw html page as post. but sounds like it doesn’t show correctly on my post pages. my html page has title there!

  <meta charset="utf-8">
  <title>Example html post</title>

How show I change my theme to show my raw html posts?

put it under /static/post, it will only copied.
/static/<path> will get /<path>

1 Like

another option is to create a _default/ layout file called blank.html that only shows {{ .Content | safeHTML }} then set the frontmatter layout to this:

layout: blank

This way you don’t need to separate your content.

1 Like

You can also put raw HTML in /content without front matter.


Please put it as hint under or so

I try the solutions but sounds like not work as expected. so I switch to a more simple theme XMin by Yihui.

That theme is easy to understand so I change below file:
{{ partial “header.html” . }}

{{if not .IsHome }}
<h1>{{ .Title | markdownify }}</h1>
{{ end }}

{{ .Content }}

  {{ range (where .Data.Pages "Section" "!=" "") }}
    <span class="date">{{ .Date.Format "2006/01/02" }}</span>
    {{if .Title }}
        <a href="{{ .URL }}">{{ .Title | markdownify}}</a>
    {{ else if in .File.BaseFileName "index" }}
        <a href="{{ .URL }}">{{ replaceRE ".*?([^/]+)/$" "$1" .File.Dir }}</a>
    {{ else }}
        <a href="{{ .URL }}">{{ .File.BaseFileName | humanize | title}}</a>
    {{ end }}
  {{ end }}

{{ partial "footer.html" . }}

Now I can see my html page on list but the date for html post is 0001/01/01 always:
2017/06/14 Another Note on A blogdown Tutorial
* 2017/06/13 A Quick Note on Two Beautiful Websites
* 2016/02/14 A Plain Markdown Post
* 2015/07/23 Lorem Ipsum
* 0001/01/01 2018 11 22 Hello
* 0001/01/01 filetransfer

Even if I change the html name to 2018-11-22-hello.html, it doesn’t work!

How can I modify the theme to get correct html page date?

The draft version has been pushed to Hugo-xmin.git

The example html page is content/post/2018-11-22-hello.html

We can assist, but we need to see your project to understand why that is happening. For instance, that could be caused by your config, the theme template, or the front matter in the content. Check out Requesting Help and share a repo and I’m sure someone will figure it out. :slight_smile:

Thanks! I have updated my post and put the github link there

You need to attach the page date to the page. This is normally done in front matter, but Hugo-xmin/2018-11-22-hello.html at master · wjj1928/Hugo-xmin · GitHub doesn’t contain front matter.

I believe you can put front matter at the top of HTML files, search the forums and read up on it, that is a possible fix. :slight_smile:

Great, I can fix it by add below lines at the beginning of html file:

title: hello html
date: ‘2018-11-22’
- Example
- Markdown

But as a user, I wish only copy a html page to folder then everything is done! if no such header there, then use file creation date as date! how can we add code to implement it in theme?

Change your config file to get the file modification time.

Can you give an example files? thanks