Published: Sun 24 August 2025
By Sissy Becky
In journal .
tags: code web1.5
A quick note first...
This is my own personal kink site. If you happened to stumble here becuase you wanted to figure out how to publish to neocities from pelican, welcome!
Feel free to look around, but I'll level with you: It's gonna get weird. Real weird. If you're not okay with that, then I encourage you to steal my code, and exit stage left.
On with the code...
It's fun having my own little personal site again. Since I'm a fuckin nerd, I like poking around and seeing how I can make things better. Turns out there is a python library to interact with the neocities api. Horray for NeoCitizen !
So, if you ever wanted to publish your pelican site to neocitizen, here is the deal. Inside of your pelican tasks.py
you need to add three things.
At the top...
You'll want to add the following line, near the top of the file, probably at the bottom of the from foo import bar
lines:
from neocitizen import NeocitiesApi
At this point you'll also want to get that package. Your command wil look something like
Fun fact, that will give you a command line neocities tool that you might find useful! heck the documentation.
Add your API Key to the config
I'm still learning python and pelican, so there is probably a better way to do this. but in the block like this, add it like so:
CONFIG = {
"settings_base": SETTINGS_FILE_BASE,
# ... a bunch of other lines
"port": 8000,
"neocities_api_key":"ab1ed00d00d1a9ee"
}
And Finally...
All you need to do is add a task. I put this right after the publish task:
@ task
def neopublish ( c ):
"""Publish to neocities"""
api = NeocitiesApi ( api_key = CONFIG [ "neocities_api_key" ], verbose = True )
api . upload_dir ( dir = CONFIG [ "deploy_path" ], dir_on_server = "." )
Then invoke some magic!
from your command line, you can run invoke neopublish
and it will publish your last built site! If you want to build and publish at the name time invoke build neopublish
wil do the trick.
I hope this helps someone. let me know what you think!