How can I configure Zola to act just as the blog for my otherwise static website (exported from Wordpress)?

I’ve exported my site from Wordpress as a static site and moved it to the static directory. Zola gives a faithful reproduction of my website when I run:

zola build; zola serve

Of course, the legacy blog is now unmaintainable without Wordpress and that’s what I want Zola to replace. The documentation is very good, but I’m not sure where to start. My homepage is a static page and I have head.html and foot.html files in the template directory giving me consistent menus and footers across the site. So I just need an index page for the blog to live at /blog. Then I’ll start recreating each blog entry in markdown. Any pointers appreciated!

I’m on zola 0.19.2 from macOS brew.

Replying to my own post because an AI chatbot helped me figure it out. I don’t know if all of these steps were necessary, but this is what helped add a path to my static site where Zola can manage the blog:

  1. Edit config.toml and under [extra] add:
    blog = "/blog/[slug]"
    /blog is the path I want the blog index to be at and [slug] represents the varying titles of each potential blog post. On the filesystem though, this has to be created in content, so something like ‘mkdir content/blog’.

  2. In the templates directory, create section.html that will be used as the index page. Mine looks like this, but it’s just a functional test:

 <!DOCTYPE html>
 <html>
 <head>
     <title>{{ section.title }}</title>
 </head>
 <body>
     <h1>{{ section.title }}</h1>
     <ul>
         {% for post in section.pages %}
             <li><a href="{{ post.permalink }}">{{ post.title }}</a></li>
         {% endfor %}
     </ul>
 </body>
 </html>
  1. In the content/blog directory, create an _index.md. Mine contains:
 +++
 title = "My Blog"
 +++
 
 # Welcome to my new blog
  1. For each blog post you want, create a markdown file in the content/blog directory following the formatting guidelines.

I’m not clear why both the section.html and the _index.md are necessary. Can anyone explain that? Also, the “Welcome to my new blog” text in step 3 does not show so I obviously need to learn more about what elements of sections are and are not used to build the blog.

I’d recommend reading the Zola overview. Overview | Zola It walks through the difference between a section, page, and template.

At a high level, Zola splits your content from rendering templates. They go in content where a section maps to a path (i.e. content/blog would be /blog). The _index.md specifies attributes about this section type and can also have content which would be displayed at /blog

All other markdown pages inside content/blog (in this example) would become /blog/[slug] where the slug is the slugified pathname or the name in the frontmatter.

You specify for these what template to use in the _index.md with template (for section) and page_template for pages.

If you want the section’s _index.md content you can access it with {{ section.content }}

1 Like