Converting an existing website into hugo

I’m converting an existing single html page site into hugo, and will be using hugo for the remaning project documentation.
What’s the right way to import the existing /index.html file ? Putting it in /static/ just gets overwritten during generation.

I’ve split the index.html into a bunch of partials under my theme/layouts, but I’m not sure how to tell hugo to use the root/index.html instead of the default index.html:

    |-- _default/
    |   |-- list.html
    |   `-- single.html
    |-- index.html
    |-- partials/
    |   |-- foot.html
    |   |-- head.html
    |   `-- sidebar.html
    |-- post/
    |   `-- single.html
    `-- root/
        |-- content.html
        |-- contributing.html
        |-- foot.html
        |-- headline.html
        |-- index.html
        `-- sponsors.html
2 Likes

Hugo will use layouts/index.html for the home page. I’m not sure if that’s what you’re asking for with the “default index.html.”

If you mean that you want to use it as the default template for your Hugo generated site, copy it into layouts/_default/list.html.

thanks @michael_henderson I’m concerned that somehow this index.html may be needed for other content? Or is it only used for the homepage?

I’ve got this working so far in https://github.com/skunkwerks/swirl/tree/master/site/ now, see https://github.com/skunkwerks/swirl/blob/master/site/themes/hyde-x/layouts/index.html for details. I’d prefer this template separate from the theme so I can easily update to latest theme each time without breaking my old changes.

/layouts/index.html is only used for the homepage. If you want to use the same layout in other places, a simple include would work well.

It does look to me like you’re not quite using the themes the way they are intended… I also think this is something that isn’t very clear yet in the docs.

Allow me to explain.

/themes is meant for 3RD PARTY themes. Other than placing them there, they aren’t meant to be touched. This allows for easy future updates.

/themes could also be used when sharing a single layout across many of your own sites. Again you wouldn’t change it in each site, but rather a single external repository.

/layouts is local. It’s meant for either the templates that pertain only to this site, or templates that override the templates in the theme.

The structure of a theme and the structure of /layouts completely mirror each other.

Does that make sense?

2 Likes

Thanks Steve, I was pretty sure I’m doing this wrong – so I put my custom things into /layouts, cleaned up the theme and it looks great again! If you are ok to check it, same links apply above. Next steps are to link in the hugo doc parts into the overal site.