]> BookStack Code Mirror - api-scripts/blob - php-generate-sitemap/readme.md
Update README.md
[api-scripts] / php-generate-sitemap / readme.md
1 # Generate Sitemap
2
3 This script will scan through all pages, chapters books and shelves via the API to generate a sitemap XML file.
4
5 **This is a very simplistic single-script-file example of using the endpoints API together**
6 , it is not a fully-featured & validated script. 
7
8 Keep in mind, The sitemap generated will reflect content visible to the API user used when running the script. 
9
10 ## Requirements
11
12 You will need php (~7.2+) installed on the machine you want to run this script on.
13 You will also need BookStack API credentials (TOKEN_ID & TOKEN_SECRET) at the ready.
14
15 ## Running
16
17 ```bash
18 # Downloading the script
19 # ALTERNATIVELY: Clone the project from GitHub and run locally.
20 curl https://raw.githubusercontent.com/BookStackApp/api-scripts/main/php-generate-sitemap/generate-sitemap.php > generate-sitemap.php
21
22 # Setup
23 # ALTERNATIVELY: Open the script and edit the variables at the top.
24 export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
25 export BS_TOKEN_ID=abc123 # Set to be your API token_id
26 export BS_TOKEN_SECRET=123abc # Set to be your API token_secret
27
28 # Running the script
29 php generate-sitemap.php <output_file_name>
30 ```
31
32 ## Examples
33
34 ```bash
35 # Create a sitemap called "sitemap.xml within the current directory
36 php generate-sitemap.php ./sitemap.xml
37 ```