Search code examples
blogspelicanstatic-site

In Pelican, how to create a page dedicated to hosting all the blog articles?


In pelican, by default, blog articles are listed on the index.html file.

What I want instead is that I use a static page as my home page and put all the blog articles on a dedicated "Blog" page.

How can I get this done?


Solution

  • While there are several possible methods for achieving your desired goals, I would start with the following changes to your settings file:

    SITEURL = '/blog'
    OUTPUT_PATH = 'output/blog'
    PAGE_URL = '../{slug}.html'
    PAGE_SAVE_AS = '../{slug}.html'
    DISPLAY_PAGES_ON_MENU = False
    DISPLAY_CATEGORIES_ON_MENU = False
    MENUITEMS = [('Home', '/'), ('Blog', '/blog/')]
    

    Put your blog posts in content/ as usual, and then create your home page with the following headers and save as content/pages/home.md:

    Title: Home
    URL: ../
    Save_as: ../index.html
    
    This is the home page.
    

    Caveats:

    1. Dynamic navigation menu generation has been effectively turned off since it doesn't work well with this configuration. Highlighting for the currently-active menu item — a feature you normally get out-of-the-box — will not be present in this configuration and, if desired, must be implemented separately in your theme.

    2. If your theme's base.html template has a link to your site home that depends on SITEURL (e.g., as the notmyidea theme does), you will need to change the link to point to <a href="/"> instead.