Enrique
Enrique

Reputation: 10137

Set custom initial page in blogdown

Is it possible to set the initial page in blogdown? Instead of the default one that shows the posts I would like to have a custom one. I want to have my own index.html (the root one).

Thanks.

enter image description here

Upvotes: 1

Views: 417

Answers (1)

n m
n m

Reputation: 1811

Assuming you are using Lithium - A simple responsive Hugo theme, one possible way to do this is the following.

1] Copy layouts/_default/list.html to a new layout file named layouts/_default/home.html

2] Edit layouts/_default/home.html so it contains this:

{{ partial "header.html" . }}

<main class="content" role="main">

<h1>
My heading
</h1>

<p>
My paragraph
</p>

</main>

{{ partial "footer.html" . }}

Your home page will now contain "My heading" and "My paragraph," along with the Lithium header and footer. If you do not want to use the Lithium header and/or footer, remove those partial calls from home.html.[*] There's a lot more that you can do with Hugo layout files, which you can learn about in my Hugo tutorial in the section 15. Explore the layouts directory and at gohugo.io's Category: templates.

I hope this is enough to get you started with Hugo layout files.

[*] If you remove the header partial, you need to put something like <!doctype html><title>a</title> at the top. More about this is in What's a valid HTML5 document? - Stack Overflow

Upvotes: 2

Related Questions