zhaohuabing / hugo-theme-cleanwhite

A clean, elegant blog theme for hugo
Apache License 2.0
730 stars 339 forks source link

Changing home to About instead of All Posts #153

Open adrianauscanga opened 1 year ago

adrianauscanga commented 1 year ago

Hi! Thank you for creating this theme. I'm using your theme for my personal website. I would like the home page to be my About page instead of my blog Posts but I can't find where to change that. I was wondering if it's possible to modify that and if so, would you point me to the right direction? Thank you very much!

Adriana

zhaohuabing commented 1 year ago

It's a bit tricky but Hugo actually allows you to override the default index page.

#create a layout directory in the root of your blog source code if you don't have one
mkdir layout
# copy the default index page to the layout directory we just created
cp themes/hugo-theme-cleanwhite/layouts/index.html layouts/index.html

Then modify the content of the index.html to include your about page. The below example is based on my web site, so you 'll need to adjust a little bit to suite yours.

{{ define "main" }}
  <!-- Post Content -->
<article>
  <div class="container">
      <div class="row">
          <!-- Post Container -->
          <div class="
          col-lg-8 col-lg-offset-1
          col-md-8 col-md-offset-1
          col-sm-12
          col-xs-12
          post-container">
          {{$file :=  "/about/index-zh.md"}}   #link to your about page 
          {{ $file | readFile | markdownify}}
          {{ partial "comments.html" . }}
          </div>
          {{ partial "sidebar.html" . }}
      </div>
  </div>
</article>
{{ end }}
adrianauscanga commented 1 year ago

This is super useful, thank you so much!

Adriana


De: zhaohuabing @.> Enviado: martes, 6 de junio de 2023 09:12 p. m. Para: zhaohuabing/hugo-theme-cleanwhite @.> Cc: Adriana Uscanga Castillo @.>; Author @.> Asunto: Re: [zhaohuabing/hugo-theme-cleanwhite] Changing home to About instead of All Posts (Issue #153)

It's a bit tricky but you can override the default index page.

create a layout directory in the root of your blog source code if you don't have one

mkdir layout

copy the default index page to the layout directory we just created

cp themes/hugo-theme-cleanwhite/layouts/index.html layouts/index.html

Then modify the content of the index.html to include your about page. The below example is based on my web site, so you 'll need to adjust a little bit to suite yours.

{{ define "main" }}

{{$file := "/about/index-zh.md"}} #link to your about page {{ $file | readFile | markdownify}} {{ partial "comments.html" . }}
{{ partial "sidebar.html" . }}

{{ end }}

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/zhaohuabing/hugo-theme-cleanwhite/issues/153*issuecomment-1579854140__;Iw!!C5qS4YX3!GpWy87NyUtpTcAkwfxQq1KEgm1frXDMP36paeRUoF5Pt8BczCz2UHC3WZZSWm8OOhNPWkwPMsiYTmMeFO4wiGxUlBOs$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ALY7HQMX4SAIVNKDFIY6CJ3XJ75TFANCNFSM6AAAAAAY4RRBEM__;!!C5qS4YX3!GpWy87NyUtpTcAkwfxQq1KEgm1frXDMP36paeRUoF5Pt8BczCz2UHC3WZZSWm8OOhNPWkwPMsiYTmMeFO4wiAWAYxKc$. You are receiving this because you authored the thread.Message ID: @.***>