How To Make Using Neocities About A Billion Times More Tolerable

So, I like Neocities. I think it's really great that someone out there is dedicated to providing free static HTML hosting, like the good old days.

You know what I don't like? Neocities' garbage HTML editor. It's an iframe in-browser, and it has none of the advantages that writing HTML in an actual IDE would have. Plus, it can kinda break if you refresh the page, and sometimes things revert, and--

It's a mess, is what I'm saying. Their entire backend GUI is kind of a mess. If you want to edit an HTML file in an actual IDE, you'd have to download the file, edit it, and re-upload it. Plus, it makes it kind of hard to keep a local backup of your site, you'd have to redownload the site every time you change something. And actually sending in the files via FTP is a no-go, since you have to pay $5 a month for that, and you want to use the service for free.

Well, what can you do? Use the CLI, that's what!

But Chaia! I don't like using the command line. I wanna use a GUI. I don't wanna type "neocities push /" every time I change something!

That's fine. If you can stomach using the CLI for ten minutes, then you'll have all the benefits of it without having to use it ever again!

This article diverges here, depending on if you want to also commit your website to a GitHub repo, or if having a local backup on your computer is enough for you.

With GitHub

See, what we're going to do is pipe your website through a GitHub repo, and use a Git Hook to push it to Neocities whenever you update your website on GitHub. You just need a GitHub account, an IDE (I did this via Visual Studio Code, but you use whatever you like), Git, and Ruby. If your website is already on Neocities, what you do is go into their horrible GUI and click the "Download entire site" link. Unpack the zip into a dedicated folder, and that'll be the folder we make our GitHub repo. If you don't actually have a website yet, just make a folder.

From there, in either your IDE's terminal or a CLI, moved into your directory either way, you type:

git init
git add .
git commit -m "First commit"

Then you go into GitHub, create a new repository, and you copy the code from GitHub's website into your terminal:

git remote add origin <your github repo here>
>> git branch -M main
>> git push -u origin main

So, congrats, you've got a folder pushing to a GitHub repo. This part is pretty obvious to anyone who's used GitHub before, but I figured explicit instructions can't hurt.

But Chaia! What does this have to do with Neocities!? This is just pushing my site to GitHub, and I want my site on Neocities!

Well, my friend, that's where the Neocities CLI comes into play. If you've got Ruby installed, you type gem install neocities into your terminal, then run neocities list /, or one of the other subcommands, which will prompt you to log into your Neocities account on the Neocities CLI. It doesn't matter what the command is, the point is to login to the CLI.

Once you've done that, switch your terminal to Git Bash if you've been working in PowerShell, and copy the following lines, either from here or from the Neocities CLI page.

printf '#!/bin/sh\nneocities push .' >.git/hooks/pre-push && \
chmod u+x .git/hooks/pre-push

This will create a Git Hook that will push any changes to your site directly to Neocities whenever you push a commit to GitHub.

Aaaand you're done! You never have to touch the Neocities CLI or their horrible HTML editor again, you can just push to GitHub through your IDE and the hook will automatically push the changes through to Neocities!


Without GitHub

See, what we're going to do is use a Git Hook to push your website to Neocities whenever you update it. You just need an IDE (I did this via Visual Studio Code, but you use whatever you like), Git, and Ruby. If your website is already on Neocities, what you do is go into their horrible GUI and click the "Download entire site" link. Unpack the zip into a dedicated folder, and that'll be the folder we make our repo. If you don't actually have a website yet, just make a folder.

From there, in either your IDE's terminal or a CLI, moved into your directory either way, you type:

git init
git add .
git commit -m "First commit"

So, congrats, you've got a folder being used as a repo. This part is pretty obvious to anyone who's used Git before, but I figured explicit instructions can't hurt.

But Chaia! What does this have to do with Neocities!? This is just creating a Git repo, and I want my site on Neocities!

Well, my friend, that's where the Neocities CLI comes into play. If you've got Ruby installed, you type gem install neocities into your terminal, then run neocities list /, or one of the other subcommands, which will prompt you to log into your Neocities account on the Neocities CLI. It doesn't matter what the command is, the point is to login to the CLI.

Once you've done that, switch your terminal to Git Bash if you've been working in PowerShell, and copy the following lines, which I've modified to work without GitHub.

printf '#!/bin/sh\nneocities push .' >.git/hooks/pre-commit && \
chmod u+x .git/hooks/pre-commit

This will create a Git Hook that will push any changes to your site directly to Neocities whenever you commit your changes.

Aaaand you're done! You never have to touch the Neocities CLI or their horrible HTML editor again, you can just commit via your IDE and the hook will automatically push the changes through to Neocities!

Return to Writings