2025-05-31 11:01:43 PM
Status:
Tags:
Ubuntu Server 24.04.2 LTS Linux
venv Instructions (I'm using these)
The process for updating an existing MkDocs site is to first edit the source content in the MkDocs site that you created during initial setup. For me, that's located in ~/knowledge-base/my-project
To do that, navigate to the directory where MkDocs lives and reactivate your venv before making the changes and building:
cd ~/knowledge-base
source .venv/bin/activate
After you've made your desired modifications, build the updated site with this command:
cd ~/knowledge-base/my-project
mkdocs build
That generates a fresh copy of your site in the ~/knowledge-base/my-project/site
directory.
At this point, you can deactivate your venv with this command:
deactivate
Remove the old deployed files:
sudo rm -rf /var/www/site-name/*
For me, it's this:
sudo rm -rf /var/www/docs.bitwyre.cc/*
Copy the new build from the site
directory:
sudo cp -r ~/knowledge-base/my-project/site/* /var/www/site-name/
For me, it's this:
sudo cp -r ~/knowledge-base/my-project/site/* /var/www/docs.bitwyre.cc/
[!NOTE] Note You could also just copy the files over from the
site
directory and overwrite rather than deleting the old files first, but that's only if you know you only made edits and/or added files. If you removed any files while editing, those files will not be removed in your live site unless you also remove them there.
Now the changes should reflect on your website.
Non-venv Instructions (I'm not using these)
[!NOTE] Note Don't follow these instructions unless you have some reason you don't want to use the venv method. These instructions do work though.
The process for updating an existing MkDocs site is to first edit the source content in the MkDocs site that you created during initial setup. For me, that's located in ~/knowledge-base
.
After you've made your desired modifications, build the updated site with this command:
cd ~/knowledge-base
mkdocs build
That generates a fresh copy of your site in the ~/knowledge-base/site
directory.
Remove the old deployed files:
sudo rm -rf /var/www/site-name/*
For me, it's this:
sudo rm -rf /var/www/docs.bitwyre.cc/*
Copy the new build from the site
directory:
sudo cp -r ~/knowledge-base/site/* /var/www/site-name/
For me, it's this:
sudo cp -r ~/knowledge-base/site/* /var/www/docs.bitwyre.cc/
[!NOTE] Note You could also just copy the files over from the
site
directory and overwrite rather than deleting the old files first, but that's only if you know you only made edits and/or added files. If you removed any files while editing, those files will not be removed in your live site unless you also remove them there.