Skip to content

ryancheley/pelican-to-sqlite

pelican-to-sqlite

PyPI GitHub changelog Tests License pre-commit.ci status

What is pelican-to-sqlite?

pelican-to-sqlite helps you add powerful search capabilities to your Pelican static site. By converting your Pelican posts into a SQLite database, you can quickly search through all your content using Datasette—without needing a complex backend or search service.

Perfect for bloggers and content creators who want to offer visitors an easy way to search through years of posts.

Prerequisites

  • Python 3.8 or higher
  • An existing Pelican site
  • Basic familiarity with command-line tools

How to install

Using uv (recommended)

uv add pelican-to-sqlite

Using pip

pip install pelican-to-sqlite

Usage

Configure the Plugin

After installing, add the plugin to your Pelican configuration file (pelicanconf.py):

PLUGINS = ['pelican_to_sqlite']

Generate the Database

Run your Pelican build command to create the SQLite database:

make html

This creates a SQLite database called pelican.db in the root of your Pelican site, containing all your post data.

Add Search to Your Site

Add a search form to your base.html template (or similar template depending on your theme). Here's an example using Tailwind CSS:

<section class="relative h-8">
    <section class="absolute inset-y-0 right-10 w-128">
        <form class="pl-4" action="your-action-link-here" method="get">
            <label for="site-search">Search the site:</label>
            <input type="search" id="site-search" name="text"
                   aria-label="Search through site content">
            <button class="rounded-full w-16 hover:bg-blue-300">Search</button>
        </form>
    </section>
</section>

Replace your-action-link-here with the URL from your deployed Datasette instance (see deployment section below).

Deploy using Vercel

You can deploy your SQLite database with Datasette using several methods. Below is a guide for deploying with Vercel.

Note: The datasette-publish-vercel plugin may have limited maintenance. Consider alternative deployment methods like Datasette Cloud or manual Vercel deployment if you encounter issues.

First, install datasette using uv (or pip)

uv add datasette
# or: pip install datasette

Next, install the datasette plugin datasette-publish-vercel using uv (or pip)

uv add datasette-publish-vercel
# or: pip install datasette-publish-vercel

and the Vercel CLI

Run vercel login to log in to (or create) an account.

Publish your pelican.db to Vercel by running:

datasette publish vercel pelican.db

For additional publishing options, see the datasette-publish-vercel documentation.

Using with Datasette

The SQLite database produced by this tool is designed to be browsed using Datasette. For a detailed implementation guide, see the blog post Adding Search to My Pelican Blog with Datasette.

Getting Help

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Author

Created by Ryan Cheley

About

A plugin to take your published Pelican posts and put them into a SQLite database

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors