Giter Club home page Giter Club logo

oni-sitemap-plugin's Introduction

Open ONI Sitemap Plugin

This provides a new command to build a full sitemap for an Open ONI site. Currently there is no configuration, and this is more a proof of concept than anything else.

Compatibility

The "main" branch should not be considered stable. Unlike the core Open ONI repository, plugins don't warrant the extra overhead of having separate development branches, release branches, etc. Instead, it is best to find a tag that works and stick with that tag.

Setup

Download the repository into the Open ONI's onisite/plugins directory as sitemap:

git clone [email protected]:jechols/oni-sitemap-plugin.git sitemap

onisite.plugins.sitemap needs to go in your INSTALLED_APPS list, e.g.:

# onisite/settings_local.py

INSTALLED_APPS = (
    'django.contrib.humanize',
    'django.contrib.staticfiles',

    'onisite.plugins.sitemap',
    'themes.default',
    'core',
)

You must create a custom sitemap file in your ONI static files directory (typically static/sitemap-custom.xml). At a minimum, you likely want your homepage, but any URLs that aren't covered by this tool, which you want crawled by search engines, can be added. This project contains an example you can base your custom sitemap on.

Usage

This just adds a new build_sitemap management command. Execute that as you would any other management command, and your sitemaps will be created, e.g.:

cd /opt/openoni
./manage.py build_sitemap

Cron

You probably want to run this in a cron job, and likely not too often, as it can take a long time to produce a list of every important URL on your site.

We put this into /etc/cron.daily/build-sitemap.sh:

#!/bin/bash
cd /opt/openoni
source ENV/bin/activate
./manage.py build_sitemap >/var/log/build-sitemap.log 2>&1

robots.txt

We included the sitemap information in robots.txt in order to ensure search engines are likely to find it easily. Most search engines appear to check for a sitemap, but it doesn't hurt to explicitly specify it. e.g.,

Sitemap: https://oregonnews.uoregon.edu/sitemap.xml

Apache Setup

You will want your web server to serve up sitemap files, as ONI currently doesn't do this (partly to avoid search engine hits that have to go through the whole Django stack).

For Apache, Open ONI has a mostly-working example of how to set this up, but the two directives you'll have to include are below:

AliasMatch ^/sitemap.xml$ /opt/openoni/static/sitemaps/sitemap.xml
AliasMatch ^/(sitemap-\w+.xml)$ /opt/openoni/static/sitemaps/$1

Note that, as of the time of creating this plugin, ONI's example assumes you'll only have sitemap.xml and sitemap-<number>.xml. With the addition of a custom sitemap, the second rule above would replace the digits-only match in the ONI example.

oni-sitemap-plugin's People

Contributors

jechols avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.