Wilr\GoogleSitemaps\GoogleSitemap
Sitemaps are a way to tell Google about pages on your site that they might not otherwise discover. In its simplest terms, a XML Sitemap usually called a Sitemap, with a capital S—is a list of the pages on your website.
Creating and submitting a Sitemap helps make sure that Google knows about
all the pages on your site, including URLs that may not be discoverable by
Google's normal crawling process.
The GoogleSitemap handle requests to 'sitemap.xml' the other two classes are
used to render the sitemap.
You can notify ("ping") Google about a changed sitemap automatically whenever
a new page is published or unpublished.
By default, Google is not notified, and will pick up your new sitemap
whenever the GoogleBot visits your website.
To Enable notification of Google after every publish set google_notification_enabled
to true in the googlesitemaps.yml config file.
This file is usually located in the _config folder of your project folder.
e.g mysite/_config/googlesitemaps.yml
<example>
---
Name: customgooglesitemaps
After: googlesitemaps
---
Wilr\GoogleSitemaps\GoogleSitemap:
enabled: true
objects_per_sitemap: 1000
google_notification_enabled: true
use_show_in_search: true
</example>
Synopsis
- // members
- private static array $dataobjects = ;
- private static array $routes = ;
- private static boolean $exclude_redirector_pages = true;
- private static array $search_indexes = ;
- // methods
- public static void register_dataobject()
- public static void register_dataobjects()
- public static bool is_registered()
- public static void unregister_dataobject()
- public static void clear_registered_dataobjects()
- public static void register_route()
- public static void register_routes()
- public static void clear_registered_routes()
- public ArrayList getItems()
- public static ArrayList get_items()
- public static string get_frequency_for_class()
- public static float get_priority_for_class()
- public ArrayList getSitemaps()
- public static ArrayList get_sitemaps()
- public static boolean ping()
- public static boolean enabled()
- public static GoogleSitemap inst()
- protected string sanitiseClassName()
Hierarchy
Uses
- SilverStripe\Core\Extensible
- SilverStripe\Core\Injector\Injectable
- SilverStripe\Core\Config\Configurable
Tasks
Line | Task |
---|---|
253 | migrate to extension hook or DI point for other modules to |
Members
private
- $dataobjects
—
array
List of {@link DataObject} class names to include. As well as the change frequency and priority of each class. - $exclude_redirector_pages — boolean
- $routes
—
array
List of custom routes to include in the sitemap (such as controller subclasses) as well as the change frequency and priority. - $search_indexes — array
Methods
protected
- sanitiseClassName() — Sanitise a namespaced class' name for inclusion in a link
public
- clear_registered_dataobjects() — Clears registered {@link DataObjects}. Useful for unit tests.
- clear_registered_routes() — Clears registered routes
- enabled() — Is GoogleSitemap enabled?
- getItems() — Constructs the list of data to include in the rendered sitemap. Links can include pages from the website, dataobjects (such as forum posts) as well as custom registered paths.
- getSitemaps() — The google site map is broken down into multiple smaller files to prevent overbearing a server. By default separate {@link DataObject} records are keep in separate files and broken down into chunks.
- get_frequency_for_class() — Returns the string frequency of edits for a particular dataobject class.
- get_items() — Static interface to instance level ->getItems() for backward compatibility.
- get_priority_for_class() — Returns the default priority of edits for a particular dataobject class.
- get_sitemaps() — Static interface to instance level ->getSitemaps() for backward compatibility.
- inst() — Convenience method for manufacturing an instance for hew instance-level methods (and for easier type definition).
- is_registered() — Checks whether the given class name is already registered or not.
- ping() — Notifies search indexes about changes to your sitemap. This behavior is disabled by default, to enable, read the documentation provided in the docs folder.
- register_dataobject() — Decorates the given DataObject with {@link GoogleSitemapDecorator} and pushes the class name to the registered DataObjects.
- register_dataobjects() — Registers multiple dataobjects in a single line. See {@link register_dataobject} for the heavy lifting
- register_route() — Register a given route to the sitemap list
- register_routes() — Registers a given list of relative urls. Will be merged with the current registered routes. If you want to replace them, please call {@link clear_routes}
- unregister_dataobject() — Unregisters a class from the sitemap. Mostly used for the test suite