Skip to content
KB4IT Help

Publish on any web server

How-to guide Publishing basic
On this page

The website is the target/ folder. It is plain HTML, CSS and JavaScript, so anything that serves files can publish it. No PHP, database or KB4IT is needed on the server.

Copy it to a server

rsync -av --delete ~/mykb/target/ www.example.com:/var/www/kb/

--delete removes pages you deleted from the knowledge base. Run the command after every build, or add it to bin/compile.sh.

Serve it with nginx

server {
    listen 80;
    server_name kb.example.com;
    root /var/www/kb;
    index index.html;
}

Show your own page for a missing address

techdoc, blog and bookshelf write 404.html at the top of the site. GitHub Pages shows it on its own. Other servers need one line.

nginx, inside the server block:

error_page 404 /404.html;

Apache, in the site configuration or .htaccess:

ErrorDocument 404 /404.html

The server shows the same file for a missing address at any depth, so a relative link in it only works at the top of the site. Set site_url in repo.json and the page uses absolute links and a <base> element, which works at any depth. kb4it serve also answers a missing page with 404.html and status 404; it points the <base> element at its own address, so the page loads its files from the local copy, not from site_url.

Preview it on your computer

Most pages work when opened from disk. To test it as a real website:

cd ~/mykb/target
python3 -m http.server 8000

Then open http://localhost:8000/. The terminal interface does the same with Browse via Web Server.

Share it without a server

Copy target/ to a shared folder or a USB stick and open index.html. The techdoc theme can also offer the whole site as a zip file on an admin page; see techdoc.

Private documents

Anyone who can open the website can read every page, and the Markdown sources unless "publish_sources": false. Protect the server with the access control your web server offers.