How do I Create HTML Pages?

I’ve been using HUGO for some time, but I’ve been unable to find out how to add a standard HTML page to my site. I have an HTML homepage named “index.html” in the layouts directory I’ve used for years. However, I don’t know how to create a new HTML page; I only know how to create new markdown pages.

The reason I want to create an HTML page is that I have several markdown pages, which simply call an HTML shortcode that makes up the entire page. I believe using HTML would be more ideal in this case. I also need to include partials, such as my header and footer, on these HTML pages.

Thanks in advance for any input.

you may just place a html file in your content directory

/content/posts/
 -- page-1.md
 -- page-2.html

this will be processed by your templates if you add a frontmatter header (can be empty)

---
title: My special html page
---

<p>{{< Ref "/tags" >}} A HTML file is just a text file containing html markup.</p>

with a standard hugo baseof.html that will create a HTML shell and directly add the paragraph.

Result
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
  <meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>My special html page | My New Hugo Site</title>

      <link rel="stylesheet" href="/css/main.min.73be4799b2091d293b47b52ca2642fe82aa2b1c9c050e8d1b389a80939a30dd4.css" integrity="sha256-c75HmbIJHSk7R7UsomQv6CqiscnAUOjRs4moCTmjDdQ=" crossorigin="anonymous">


        <script src="/js/main.23cd0c7d837263b9eaeb96ee2d9ccfa2969daa3fa00fa1c1fe8701a9b87251a1.js" integrity="sha256-I80MfYNyY7nq65buLZzPopadqj&#43;gD6HB/ocBqbhyUaE=" crossorigin="anonymous"></script>


</head>
<body>
  <header>
    <h1>My New Hugo Site</h1>

  <nav>
    <ul>
    <li>
      <a href="/">Home</a>
    </li>
    <li>
      <a aria-current="true" class="ancestor" href="/posts/">Posts</a>
    </li>
    <li>
      <a href="/tags/">Tags</a>
    </li>
    </ul>
  </nav>


  </header>
  <main>
    
  <h1>My special html page</h1>

  
  
  <time datetime="0001-01-01T00:00:00&#43;00:00">January 1, 1</time>

  
   <p>https://example.org/tags/ A HTML file is just a text file containing html markup.</p>
  


  </main>
  <footer>
    <p>Copyright 2025. All rights reserved.</p>

  </footer>
</body>
</html>

ofc you may create different layout files

you may not call partials from page-2.html directly cause it’s a content file. You will have to create a shortcode which is then calling the partial.


corrected files

Do you think this solution is better than writing the page as a shortcode and calling it within a markdown file?

I would say yes it’s cleaner than putting the page into a shortcode. (in fact also just a part cause you said you want to generate header and footer) so you work with layouts already.

and more flexible, cause you can use shortcodes inside your html just like in markdown

markdown + shortcode ( html ) + markdown => layout to html page
vs
html | layout to html page

if these files are handmade you might consider to migrate them to markdown, aswell.

all that depends on your content organization, things you cannot or do not want to change by reason. So without real stuff hard to reason.

I’m trying to implement your recommendation for testing but the HTML is displayed as text rather HTML code.

I do not have a baseof.html

i would suggest ro play around with a quite bare site setup. create one using:

hugo new theme --themesDir . mysite

you’ll find a conten folder with some posts and a layouts folder with a baseof and others

I did not know about this demo site, thanks for the tip.

I made the same changed to this new site which results in the same display.

oops, you’re right - the block definition should not be in the html source. sry

---
title: My special html page
---
<p>{{< Ref "/tags" >}} A HTML file is just a text file containing html markup.</p>


currected the code in the original post

1 Like

That works as expected, thank you. To confirm, none of the HUGO code can be in these HTML pages, they must be a shortcode?

exactly just like with a markdown file

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.