Search code examples
blogshugoblogdown

Change the main/landing page of my Hugo Blog


I am quite new to Hugo and was building a website using Hugo and R blogdown. One issue I have, is that I can not figure out how to change the first page that appears when one loads the website/clicks on the title header.

So basically I want my <website_name> to link to /about/ and to change '/' to '/about/' like:

[[menu.main]]
    name = "Home"
    url = "/"
    weight = 1
[[menu.main]]
    name = "About"
    url = "/about/"
    weight = 2

to

[[menu.main]]
    name = "Home"
    url = "/about/"
    weight = 1
[[menu.main]]
    name = "About"
    url = "/about/"
    weight = 2

It feels like it should be super easy.

Yet it ,I am not quite sure how to do so (especially changing the main page) and would appreciate some help. I hope my question is somewhat understandable


Solution

  • Solution 1. Redirect

    You can just redirect from the homepage to the about page. That is the easiest way to do this. You can use .httaccess to handle the redirect in the static dir, use a javascript redirect in the content dir or use the meta refresh tag in the index.html layout.

    Solution 2. Get the content of another page

    You can also render your about page on your main page, using with and GetPage in your index.html template. This looks like this:

    {{ with .GetPage `about.md` }}
      <h1>{{ .Title }}</h1>
      {{ .Content }}
    {{ end }}
    

    See: https://gohugo.io/functions/getpage/

    Solution 3: Change the layout

    But... maybe you just want to overwrite the layout of the index.html with the single.html and change the content of the homepage. That seems like the cleanest solution to me.