Trying to make the home page static (Hyde-Y Theme)

Hello! :smile:

Sorry, first time using a static site generator, forgive me if do any stupid mistakes :sweat_smile:. I am trying to make the front page static. That is, make it a page generated using Markdown. By default, the front page in the Hyde-Y theme displays the posts.

I tried to use _index.md but it is not working :frowning:. I placed the _index.md file in the content directory.

Using Hugo Static Site Generator v0.19 windows/amd64 BuildDate: 2017-03-25T12:33:55+05:30. Thanks in Advance!

Youโ€™ve done the first step, which is placing an _index.md inside the content folder. The second step is to modify the templating.

Open the the homepage.html partial located in /yoursite/themes/hyde-y/layouts/partials. You will see:

<section id="main-content" class="container main_content homepage">
  <header class="container header">
    {{ partial "bloc/content/h1-title" . }}
    {{ partial "bloc/content/lastupdate" . }}
  </header>
  {{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
  {{ range $paginator.Pages }}
    {{ .Render "summary" }}
  {{ end }}
  {{ partial "bloc/content/pagination" . }}
</section>

Modify the file like so:

<section id="main-content" class="container main_content homepage">
  <header class="container header">
    {{ partial "bloc/content/h1-title" . }}
    {{ partial "bloc/content/lastupdate" . }}
  </header>
  {{ .Content }}
</section>

The original file is set up for pagination. The change does what you want, and you can read more about page variables here.

Check out @rdwatters work on overhauling the documentation.

2 Likes

Thank you very much @sethm for the instructions! I was near to figuring this out but I gave up because of my understand about the template system. You saved me a lot of work and headaches :smile: :thumbsup:

Very good project, from now on, I will try to use both resource so I can figure out things easily :slightly_smiling:.

Again, Thank you! :heart:

Hopefully you wonโ€™t have to check two places for much longer.

That said, please use hugodocs.info as your main go-to moving forward and please do not hesitate to reach out with suggestions for any areas of improvement.

1 Like

Thanks for the heads up, I will use hugodocs.info as my primary resource and will try to provide useful suggestions :wink: :slightly_smiling:

1 Like

Another tip I would recommend here is to copy homepage.html to /yoursite/layouts/partials (the folder wouldnโ€™t exist, you will have to create it) and then modify the copied file to edit the template. This way we can modify page generation without messing with the theme itself :slight_smile:

I just tested and it works very well, glad that I am making progress :smiley:

4 Likes