Since Wiki.js 3.0 will officially support the sitemap function, this is a temporary method.
The method below assumes that access toassets
inside the project directory in the server environment where Wiki.js is installed and use of thecrontab
command is possible.
/home/wiki/app
/home/wiki/.scripts/wikijs-sitemap
(empty directory)cd /home/wiki/.scripts/wikijs-sitemap
npm init -y
npm install --save https://github.com/uyu423/sitemap-generator
There is an issue where the
sitemap-generator
project does not properly parse the wiki.js page.
As acheerio
version issue used in the project, a pull request is currently in progress. sitemap-generator#119
If thecheerio
of the project is up, you can use the original project.npm install sitemap-generator
😎
const SitemapGenerator = require("sitemap-generator");
const service = SitemapGenerator("https://your.wiki.address", {
filepath: "/home/wiki/app/assets/sitemap.xml",
stripQuerystring: true,
priorityMap: [0.5, 0.5, 1.0]
});
service.start();
filepath
and priorityMap
according to your own wiki.js configuration.
app/assets/*
where Wiki.js exists is mapped to the URL your.wiki.address/_assets/*
.node index.js
is executed, the sitemap-generator
crawler recursively finds the <a href>
tag in the page body and creates it as sitemap.xml.crontab
, a basic Linux utility, to update sitemap.xml once a day.crontab -e
23 4 * * * node /home/wiki/.scripts/wikijs-sitemap/index.js
sitemap.xml
every day at 04:23 amhttps://your.wiki.address/_assets/sitemap.xml
in the search engine you need.Here, we shared an example of adding
sitemap.xml
to the server local environment in a very cumbersome way.
If possible, it would be good to customize according to the server environment where Wiki.js is running.