sunpy/ablog

Custom permalinks for blog posts

Opened this issue · 0 comments

Describe the feature

Currently, ABlog uses the path to the source file for blog post permalinks, similar to any other Sphinx page. It is a common practice in the blogging world to instead have a user-defined permalink structure (e.g. /:year/:month/:day/:filename). This allows you to organize your local filesystem without requiring you to use the same URL link structure (e.g. many blogs are now only using the page title in the URL instead of adding date-based subfolders).

Proposed solution

ABlog could provide a configuration option like ablog_permalink_structure, which would take a string with a few keyword arguments that were supported. E.g.:

  • year
  • month
  • day
  • category
  • slug

And so the value could be something like:

# Month and year-based pages
ablog_permalink_structure = "{year}/{month}/{slug}"

# Just the slug
ablog_permalink_structure = "{slug}"

# Would error because the variable doesn't exist
ablog_permalink_structure = "{year}/{foo}/{slug}"