How to render multiple root level html pages

Hi everyone I’m fairly new to Hugo and I have been reading docs for few days, forums as well. I have few questions mainly related to unique page rendering at root level.

For example layouts directory has rule that renders index.html which means it treats it specially. What would be the process of rendering about.html that uses content from partials folder. But with its unique content.

My main goal is to have http://site.com shows rendered index.html and http://site.com/blog renders blog.html and i have managed to pull exactly that using approach from this post. I was wondering is there a better approach to this problem.

Thanks in advance, sorry for kinda noobish question but i’m still warpping my head around this.

Create two content files:

1. content/_index.md
2. content/about.md

Create two layouts, which will render the respective pages above:

1. layouts/index.html
2. layouts/_default/single.html

To pay me back, read the site the team is working on to improve the docs and provide feedback :wink:

6 Likes

@rdwatters Much obliged, it is elegant solution. I will be checking out and contributing however i can to docs you provided.

Thanks again.

1 Like

For a slightly different way of doing this you can take a look at a couple sites I built.

I think they will contain example of what you are wanting to do.

I have a similar problem/requirement (the same, in fact).

I have followed the advice given here, but it does not render my about.md or contact.md. When I point my browser to /about or /contact it gives me a 404 error.

If I create about.html or contact.html, that will get rendered, but that is not what I want.

What is supposed to be in my content/_index.md?

My layouts/_default/single.html contains just the following:

{{ define "main" }}

<div class="panel panel-default">
    <div class="panel-heading">
        <h1>{{ .Title }}</h1>
    </div>
    <div class="panel-body">
        {{ .Content }}
    </div>    
</div>

{{ end }} 

Never mind. It seems I eventually came right. It seems that the _index.md is not required, right?

In the end, I had accidentally changed the date in my front matter to a future date while copying the front matter from another page…

It’s not required.