Theme mainroad: how to hide posts in the main page?


#1

Hi there,

I would like to show at the main page of my website a standard text with a picture and link about our working group. But the functionality with recent posts I would like to keep also at the sidebar. In general is there such a possibility to realize that?

Thanks in advance

Sibel


#2

Generally speaking, we need some more info to be able to help you, so please have a look at Requesting Help and provide some more details like your repo etc, ok?

Regarding just having some text on the home page, yes, no problem. See:

You can put that standard text into the content section of _index.md, then in the template reference it via {{ .Content }}.

As for the sidebar list, yes, that’s also no problem. See:

The basic concept is to use range:

<nav>
  <h1>Recent Posts</h1>
  <ul>
  {{- range first 5 .Site.Pages -}}
      <li><a href="{{.RelPermalink}}">{{.Title}}</a></li>
  {{- end -}}
  </ul>
</nav>

You just have to work that into the template that builds your sidebar.


#3

In “mainroad” theme, which I have never used, looks like it is generating that home page list here:

You’d need to edit that.

The sidebar is controlled by:

Main basic structure is:


#4

Hey Rick, I ve just added my repo into github.

There you can have a look into the code, but unfortunately one can not open the mainroad theme ??? Did I do something wrong?


#5

You can fork the theme if you want to edit it directly, or, you can copy its files you intend to change, to your project folders, and they will override the theme ones when Hugo does the building.


#6

Ok I will try to do that. A general question: Do you advice to use a theme? or to construct a page by your own? Which way is easier. I dont have so much time and until the end of the year the new web page should be ready.


#7

@Sibel – Rick has given helpful info for customizing an existing theme.

If you wish to create a layout (or theme) from scratch, checkout the HTML/CSS links in the recommended reading (if needed), then checkout the hugo docs on layouts/templates.