api-scripts/php-generate-sitemap
Dan Brown f165f615fa
Fixed array concatenation in sitemap gen script
Also set sitemap output to be formatted for easier reading.
Updated example sitemap.

For #4
2021-11-09 14:36:46 +00:00
..
generate-sitemap.php Fixed array concatenation in sitemap gen script 2021-11-09 14:36:46 +00:00
readme.md Added user note 2021-03-04 23:47:56 +00:00
sitemap.xml Fixed array concatenation in sitemap gen script 2021-11-09 14:36:46 +00:00

Generate Sitemap

This script will scan through all pages, chapters books and shelves via the API to generate a sitemap XML file.

This is a very simplistic single-script-file example of using the endpoints API together , it is not a fully-featured & validated script.

Keep in mind, The sitemap generated will reflect content visible to the API user used when running the script.

Requirements

You will need php (~7.2+) installed on the machine you want to run this script on. You will also need BookStack API credentials (TOKEN_ID & TOKEN_SECRET) at the ready.

Running

# Downloading the script
# ALTERNATIVELY: Clone the project from GitHub and run locally.
curl https://raw.githubusercontent.com/BookStackApp/api-scripts/main/php-generate-sitemap/generate-sitemap.php > generate-sitemap.php

# Setup
# ALTERNATIVELY: Open the script and edit the variables at the top.
export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
export BS_TOKEN_ID=abc123 # Set to be your API token_id
export BS_TOKEN_SECRET=123abc # Set to be your API token_secret

# Running the script
php generate-sitemap.php <output_file_name>

Examples

# Create a sitemap called "sitemap.xml within the current directory
php generate-sitemap.php ./sitemap.xml