Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 960
L.J Avatar asked May 17 '14 08:05

L.J


2 Answers

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.

like image 182
Justin Mayer Avatar answered Oct 13 '22 00:10

Justin Mayer


Set the following in the pelicanconf

DIRECT_TEMPLATES = ['blog']
PAGINATED_DIRECT_TEMPLATES = ['blog']

1st line will set blog.html for the articles 2nd line will allow pagination of blog.html file

For the index page, create a pages folder in the content directory and create the .md file there and set save_as:index.html this will save the md file as index.html

like image 28
Lonewolf Avatar answered Oct 12 '22 23:10

Lonewolf