Publishing new post to Mkdocs
There are a few things that needs to be done when you want to update your site, for example upload a new post, or update an existing post. I had some trouble getting back to it after not doing it for a few weeks, so here is a detailed instruction, for myself but also for you.
Deleting the old files
Login to your webserver with for example winscp for filetransfer, or how you transfer your updated files.
Go to the folder that your mkdocs or zensical configuration is in. I have mine installed at '/root/blog/'. Delete the folder named 'site'.
Go to '/var/www/html/' and delete the same folder named 'site'.
Building the site
Open the command line on your webserver, in the site folder where the mkdocs or zensical configuration file is. Go ahead and build the site with the following command.
When you refresh on winscp, or with ls in the command line you see the folder 'site' is back. Now copy that folder back to '/var/www/html/'.Restarting the site
Run the following command to restart the site.
This should have updated your website.Creating a script to update automatically
It's not so much work to do it all manually, but I have noticed that if you update the site multiple times a day, it gets annoying to do and I started to make mistakes after a few hours. So I thought, what if I just automate it. Well, here we are!
The script
First create an upload folder, for the updated files. My upload folder is in the root directory, as seen below. Create the script with the following command.
Here is the script I'm using, you need to adjust the paths on line 4-7 to your own paths.Time for a backup!
If there is a mistake in the script, you could easily delete or edit the wrong files. So please, before you run the script, create a backup of your installation!
Run the script
If you want to run the script, add your files you want to update to the upload-blog folder and run the following command.
This should have updated the files, that you have uploaded to the upload-blog folder and restarted the website.