Erweiterung:AutoSitemap
AutoSitemap Freigabestatus: stabil |
|
---|---|
Einbindung | MeinWiki , Seitenaktivität |
Beschreibung | Erstellt und aktualisiert automatisch eine Sitemap-Datei, wenn sich die Seite einer Website ändert. |
Autor(en) | Dolfinus, François Boutines-Vignard, Jehy, Thomas |
Letzte Version | 1.8.2 (2024-10-29) |
MediaWiki | 1.28+ |
Datenbankänderungen | Nein |
Lizenz | GNU General Public License 3.0 oder neuer |
Herunterladen | Download master snapshot Hinweis: README |
Beispiel | Generierte Sitemap |
$wgAutoSitemap |
|
The AutoSitemap extension automatically builds a "sitemap.xml" file at every page create/edit/delete event. Sitemap file helps search engines to observe your site’s pages. Diese Erweiterung basiert auf der Erweiterung ManualSitemap .
Rationale
I do not have the possibility to update my sitemap via scheduler (like cron) because of the hosting provider, and I also do not want to update it manually.
So I edited an existing extension to update the sitemap by itself at any page edit, create, delete, rename, upload, etc events.
Note
This extension can be used on small MediaWiki instances (up to 10k pages). If your instance is larger than 50k pages, you should use GenerateSitemap.php instead because it does support sitemap index file, can create separated files for each namespace, compress sitemap files and also designed to be run on schedule instead of triggering after each page modification.
Installieren
- Die Erweiterung herunterladen und die Datei(en) in ein Verzeichnis namens
AutoSitemap
im Ordnerextensions/
ablegen. - Folgenden Code am Ende deiner LocalSettings.php -Datei einfügen:
wfLoadExtension( 'AutoSitemap' );
- Nehme eine Änderung an einer deiner Wikiseiten vor, z.B. erstelle eine Seite oder aktualisiere eine vorhandene
- Sitemap-Datei wird automatisch generiert
- Erledigt – Navigiere zu Special:Version in deinem Wiki, um zu überprüfen, ob die Erweiterung erfolgreich installiert wurde.
Konfigurieren
Es gibt einige optionale Parameter, die die Sitemap-Generierung ändern. Du kannst diese in deiner LocalSettings.php einstellen.
Dateiname
Du kannst den Dateinamen der Sitemap festlegen, indem du folgendes festlegst:
$wgAutoSitemap["filename"] = "sitemap.xml"; //default value
Basis-URL festlegen
By default all URLs in sitemap use $wgCanonicalServer (or $wgServer, if it doesn’t set) as domain prefix. If you want to set it to another one, you can change it manually by setting:
$wgAutoSitemap["server"] = "https://your-site.com";
Exclude types of pages from sitemap
You can exclude namespaces or exact pages from including them to sitemap:
$wgAutoSitemap["exclude_namespaces"] = [
NS_TALK,
NS_USER,
NS_USER_TALK,
NS_PROJECT_TALK,
NS_FILE_TALK,
NS_MEDIAWIKI,
NS_MEDIAWIKI_TALK,
NS_TEMPLATE,
NS_TEMPLATE_TALK,
NS_HELP,
NS_HELP_TALK,
NS_CATEGORY_TALK
]; //default values
$wgAutoSitemap["exclude_pages"] = ['page title to exclude', 'other one'];
If you need to exclude custom namespace from sitemap, pass here namespace ID (integer) instead of name constant.
Set page update frequency
You can manually specify the recommended frequency with which all addresses will be checked by search engine:
$wgAutoSitemap["freq"] = "daily"; //default
Verfügbare Werte sind:
hourly daily weekly monthly yearly adjust - for automatic determination of frequency based on page edits count
Seitenpriorität festlegen
You can manually specify priority for certain pages or namespaces:
$wgAutoSitemap["priority"] = 0.7;
oder
$wgAutoSitemap["priority"][NS_MAIN] = 1;
$wgAutoSitemap["priority"][NS_CATEGORY] = 0.8;
oder
$wgAutoSitemap["priority"]['Main page'] = 1;
$wgAutoSitemap["priority"]['Other page'] = 0.8;
Rate-limit recreation of the sitemap
For wikis with many pages, generating the sitemap may consume significant resources, so you may not want it to happen too frequently. With this option, you can specify that the sitemap should only be recreated if it's at least a certain number of seconds old.
$wgAutoSitemap["min_age"] = 3600; // 1 hour, default 0 (no rate-limit)
Verwendung
Blank page after installing extension
Please follow Handbuch:Wie man debuggt instruction to get exception message interrupting page render process.
Usually this is caused by passing undefined constant to $wgAutoSitemap["exclude_namespaces"]
.
Rechte
Your MediaWiki folder should be permitted for write operations (chmod +w
with chown apache
or chown nginx
).
Htaccess, nginx
If you want to see a human-readable sitemap, allow read access for sitemap.xsl file in your site config (.htaccess
file or other).
Siehe auch
- w:de:Sitemaps-Protokoll - Wikipedia über Sitemaps
- Google über Sitemaps