<commit_before>=====================
The sitemap framework
=====================

Django comes with a high-level sitemap-generating framework that makes
creating sitemap_ XML files easy.

.. _sitemap: http://www.sitemaps.org/

Overview
========

A sitemap is an XML file on your Web site that tells search-engine indexers how
frequently your pages change and how "important" certain pages are in relation
to other pages on your site. This information helps search engines index your
site.

The Django sitemap framework automates the creation of this XML file by letting
you express this information in Python code.

It works much like Django's `syndication framework`_. To create a sitemap, just
write a ``Sitemap`` class and point to it in your URLconf_.

.. _syndication framework: ../syndication_feeds/
.. _URLconf: ../url_dispatch/

Installation
============

To install the sitemap app, follow these steps:

    1. Add ``'django.contrib.sitemaps'`` to your INSTALLED_APPS_ setting.
    2. Make sure ``'django.template.loaders.app_directories.load_template_source'``
       is in your TEMPLATE_LOADERS_ setting. It's in there by default, so
       you'll only need to change this if you've changed that setting.
    3. Make sure you've installed the `sites framework`_.

(Note: The sitemap application doesn't install any database tables. The only
reason it needs to go into ``INSTALLED_APPS`` is so that the
``load_template_source`` template loader can find the default templates.)

.. _INSTALLED_APPS: ../settings/#installed-apps
.. _TEMPLATE_LOADERS: ../settings/#template-loaders
.. _sites framework: ../sites/

Initialization
==============

To activate sitemap generation on your Django site, add this line to your
URLconf_:

    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})

This tells Django to build a sitemap when a client accesses ``/sitemap.xml``.

The name of the sitemap file is not important, but the location is. Search
engines will only index links in your sitemap for the current URL level and
below. For instance, if ``sitemap.xml`` lives in your root directory, it may
reference any URL in your site. However, if your sitemap lives at
``/content/sitemap.xml``, it may only reference URLs that begin with
``/content/``.

The sitemap view takes an extra, required argument: ``{'sitemaps': sitemaps}``.
``sitemaps`` should be a dictionary that maps a short section label (e.g.,
``blog`` or ``news``) to its ``Sitemap`` class (e.g., ``BlogSitemap`` or
``NewsSitemap``). It may also map to an *instance* of a ``Sitemap`` class
(e.g., ``BlogSitemap(some_var)``).

.. _URLconf: ../url_dispatch/

Sitemap classes
===============

A ``Sitemap`` class is a simple Python class that represents a "section" of
entries in your sitemap. For example, one ``Sitemap`` class could represent all<commit_msg>Fixed #5890 -- Fixed a ReST markup error. Thanks, arien.<commit_after>=====================
The sitemap framework
=====================

Django comes with a high-level sitemap-generating framework that makes
creating sitemap_ XML files easy.

.. _sitemap: http://www.sitemaps.org/

Overview
========

A sitemap is an XML file on your Web site that tells search-engine indexers how
frequently your pages change and how "important" certain pages are in relation
to other pages on your site. This information helps search engines index your
site.

The Django sitemap framework automates the creation of this XML file by letting
you express this information in Python code.

It works much like Django's `syndication framework`_. To create a sitemap, just
write a ``Sitemap`` class and point to it in your URLconf_.

.. _syndication framework: ../syndication_feeds/
.. _URLconf: ../url_dispatch/

Installation
============

To install the sitemap app, follow these steps:

    1. Add ``'django.contrib.sitemaps'`` to your INSTALLED_APPS_ setting.
    2. Make sure ``'django.template.loaders.app_directories.load_template_source'``
       is in your TEMPLATE_LOADERS_ setting. It's in there by default, so
       you'll only need to change this if you've changed that setting.
    3. Make sure you've installed the `sites framework`_.

(Note: The sitemap application doesn't install any database tables. The only
reason it needs to go into ``INSTALLED_APPS`` is so that the
``load_template_source`` template loader can find the default templates.)

.. _INSTALLED_APPS: ../settings/#installed-apps
.. _TEMPLATE_LOADERS: ../settings/#template-loaders
.. _sites framework: ../sites/

Initialization
==============

To activate sitemap generation on your Django site, add this line to your
URLconf_::

    (r'^sitemap.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps})

This tells Django to build a sitemap when a client accesses ``/sitemap.xml``.

The name of the sitemap file is not important, but the location is. Search
engines will only index links in your sitemap for the current URL level and
below. For instance, if ``sitemap.xml`` lives in your root directory, it may
reference any URL in your site. However, if your sitemap lives at
``/content/sitemap.xml``, it may only reference URLs that begin with
``/content/``.

The sitemap view takes an extra, required argument: ``{'sitemaps': sitemaps}``.
``sitemaps`` should be a dictionary that maps a short section label (e.g.,
``blog`` or ``news``) to its ``Sitemap`` class (e.g., ``BlogSitemap`` or
``NewsSitemap``). It may also map to an *instance* of a ``Sitemap`` class
(e.g., ``BlogSitemap(some_var)``).

.. _URLconf: ../url_dispatch/

Sitemap classes
===============

A ``Sitemap`` class is a simple Python class that represents a "section" of
entries in your sitemap. For example, one ``Sitemap`` class could represent all
{'fraction_non_alphanumeric': 0.12265135699373696, 'fraction_numerical': 0.0017397355601948504, 'mean_word_length': 4.413370998116761, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3466099', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1654, 'n_words': 737}