• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    Elixir
  • License
    MIT License
  • Created almost 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sitemap is the easiest way to generate Sitemaps in Elixir.

Sitemap

Build Status Hex version Hex downloads Inline docs hex.pm

Generating sitemap.xml

Installation

If available in Hex, the package can be installed as:

  1. Add sitemap to your list of dependencies in mix.exs:
def deps do
  [{:sitemap, "~> 1.1"}]
end
  1. Ensure sitemap is started before your application:
def application do
  [extra_applications: [:sitemap]]
end

Usage

sitemap helps you define a module with a generate function which will build a sitemap for your site. You must decide how to call generate - via a manual Mix task, a recurring background job, or whatever you choose.

The resulting sitemap is currently written to a file. Because some web hosts do not support writing to the filesystem, we plan to support uploading to S3 in the future.

You can always specify your own adapter module with a write/2 function and persist the sitemaps wherever you like.

Basic
defmodule Sitemaps do
  use Sitemap

  def generate do
    create do
      # list each URL that should be included
      add "path1", priority: 0.5, changefreq: "hourly", expires: nil, mobile: true
      # ...
    end

    # notify search engines (currently Google and Bing) of the updated sitemap
    ping()
  end
end
With Phoenix
defmodule Sitemaps do
  alias MyAppWeb.{Endpoint, Router.Helpers}

  use Sitemap,
    host: "http://#{Application.get_env(:myapp, Endpoint)[:url][:host]}",
    files_path: "priv/static/sitemaps/",
    public_path: "sitemaps/"

  def generate do
    create do
      # list each URL that should be included, using your application's routes
      add Helpers.entry_path(Endpoint, :index), priority: 0.5, changefreq: "hourly", expires: nil
      add Helpers.entry_path(Endpoint, :about), priority: 0.5, changefreq: "hourly", expires: nil
      # ...
    end

    # notify search engines (currently Google and Bing) of the updated sitemap
    ping()
  end
end

Ways to set sitemap's options

Set options via the use statement
defmodule Sitemaps do
  use Sitemap, compress: false, host: "http://example.com"

  def generate do
    create do
      add "path1", priority: 0.5, changefreq: "hourly"
      add "path2", priority: 0.5, changefreq: "hourly"
    end

    ping()
  end
end
Set options via arguments to create
defmodule Sitemaps do
  use Sitemap

  def generate do
    create compress: false, host: "http://example.com" do
      add "path1", priority: 0.5, changefreq: "hourly"
      add "path2", priority: 0.5, changefreq: "hourly"
    end

    ping()
  end
end
Set options via Mix config
use Mix.Config

config :sitemap, [
  compress: false,
  host: "http://example.com",
]
Set options via environment variables
SITEMAP_COMPRESS=false SITEMAP_HOST=http://example.com mix run ./sitemap.exs

And you guys should follow mix task documents, here:

Available options
Name Default Value Environment -
max_sitemap_files 10000 SITEMAP_MAXFILES Max sitemap links per index file
max_sitemap_links 10000 SITEMAP_MAXLINKS Max links per sitemap
max_sitemap_news 1000 SITEMAP_MAXNEWS Max news sitemap per index_file
max_sitemap_images 1000 SITEMAP_MAXIMAGES Max images per url
max_sitemap_filesize 5000000 SITEMAP_MAXFILESIZE Bytes
host http://www.example.com SITEMAP_HOST Your domain, also host with http scheme.
filename sitemap SITEMAP_FILENAME Name of sitemap file.
files_path sitemap SITEMAP_SITEMAPS_PATH After domain path's location on URL.
public_path sitemap SITEMAP_PUBLIC_PATH Write sitemap files to this local path.
adapter Sitemap.Adapters.File SITEMAP_ADAPTER You'd change to write each filesystem
verbose true SITEMAP_VERBOSE Getting more information in sitemap working.
compress true SITEMAP_COMPRESS Gzip compression.
create_index auto SITEMAP_CREATE_INDEX Generating sitemps to this directory path.

Features

Current Features or To-Do

Supports: generate kind of some sitemaps

News Sitemaps

defmodule Sitemaps do
  use Sitemap, compress: false, host: "http://example.com"

  def generate do
    create do
      add "index.html", news: [
           publication_name: "Example",
           publication_language: "en",
           title: "My Article",
           keywords: "my article, articles about myself",
           stock_tickers: "SAO:PETR3",
           publication_date: "2011-08-22",
           access: "Subscription",
           genres: "PressRelease"
         ]
    end
  end
end
Generated Result
<url>
 <loc>http://www.example.com/index.html</loc>
 <lastmod>2016-05-30T13:13:12Z</lastmod>
 <news:news>
   <news:publication>
     <news:name>Example</news:name>
     <news:language>en</news:language>
   </news:publication>
   <news:title>My Article</news:title>
   <news:access>Subscription</news:access>
   <news:genres>PressRelease</news:genres>
   <news:keywords>my article, articles about myself</news:keywords>
   <news:stock_tickers>SAO:PETR3</news:stock_tickers>
   <news:publication_date>2011-08-22</news:publication_date>
 </news:news>
</url>

Look at Creating a Google News Sitemap as required.

Image sitemaps

defmodule Sitemaps do
  use Sitemap, compress: false, host: "http://example.com"

  def generate do
    create do
      add "index.html", images: [
           loc: "http://example.com/image.jpg",
           caption: "Caption",
           title: "Title",
           license: "https://github.com/ikeikeikeike/sitemap/blob/master/LICENSE",
           geo_location: "Limerick, Ireland",
         ]
    end
  end
end
Generated Result
<url>
 <loc>http://www.example.com/image.html</loc>
 <lastmod>2016-05-31T13:32:40Z</lastmod>
 <image:image>
   <image:loc>http://example.com/image.jpg</image:loc>
   <image:caption>Caption</image:caption>
   <image:title>Title</image:title>
   <image:license>https://github.com/ikeikeikeike/sitemap/blob/master/LICENSE</image:license>
   <image:geo_location>Limerick, Ireland</image:geo_location>
 </image:image>
</url>

Look at Image sitemaps as required.

Video sitemaps

defmodule Sitemaps do
  use Sitemap, compress: true, host: "http://example.com"

  def generate do
    create do
      add "index.html", videos: [
           thumbnail_loc: "http://www.example.com/thumbs/123.jpg",
           title: "Grilling steaks for summer",
           description: "Alkis shows you how to get perfectly done steaks every time",
           content_loc: "http://www.example.com/video123.flv",
           player_loc: "http://www.example.com/videoplayer.swf?video=123",
           allow_embed: true,
           autoplay: true,
           duration: 600,
           expiration_date: "2009-11-05T19:20:30+08:00",
           publication_date: "2007-11-05T19:20:30+08:00",
           rating: 0.5,
           view_count: 1000,
           tags: ~w(tag1 tag2 tag3),
           tag: "tag4",
           category: "Category",
           family_friendly: true,
           restriction: "IE GB US CA",
           relationship: true,
           gallery_loc: "http://cooking.example.com",
           gallery_title: "Cooking Videos",
           price: "1.99",
           price_currency: "EUR",
           price_type: "own",
           price_resolution: "HD",
           uploader: "GrillyMcGrillerson",
           uploader_info: "http://www.example.com/users/grillymcgrillerson",
           live: true,
           requires_subscription: false
         ]
    end
  end
end
Generated Result
<url>
 <loc>http://www.example.com/video.html</loc>
 <lastmod>2016-05-31T12:51:47Z</lastmod>
 <video:video>
   <video:title>Grilling steaks for summer</video:title>
   <video:description>Alkis shows you how to get perfectly done steaks every time</video:description>
   <video:player_loc allow_embed="yes" autoplay="ap=1">http://www.example.com/videoplayer.swf?video=123</video:player_loc>
   <video:content_loc>http://www.example.com/video123.flv</video:content_loc>
   <video:thumbnail_loc>http://www.example.com/thumbs/123.jpg</video:thumbnail_loc>
   <video:duration>600</video:duration>
   <video:gallery_loc title="Cooking Videos">http://cooking.example.com</video:gallery_loc>
   <video:rating>0.5</video:rating>
   <video:view_count>1000</video:view_count>
   <video:expiration_date>2009-11-05T19:20:30+08:00</video:expiration_date>
   <video:publication_date>2007-11-05T19:20:30+08:00</video:publication_date>
   <video:tag>tag1</video:tag>
   <video:tag>tag2</video:tag>
   <video:tag>tag3</video:tag>
   <video:tag>tag4</video:tag>
   <video:category>Category</video:category>
   <video:family_friendly>yes</video:family_friendly>
   <video:restriction relationship="allow">IE GB US CA</video:restriction>
   <video:uploader info="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson</video:uploader>
   <video:price currency="EUR" resolution="HD" type="own">1.99</video:price>
   <video:live>yes</video:live>
   <video:requires_subscription>no</video:requires_subscription>
 </video:video>
</url>

Look at Video sitemaps as required.

Alternate Links

defmodule Sitemaps do
  use Sitemap, compress: true, host: "http://example.com"

  def generate do
    create do
      add "index.html", alternates: [
           href: "http://www.example.de/index.html",
           lang: "de",
           nofollow: true,
           media: "only screen and (max-width: 640px)"
         ]
    end
  end
end
Generated Result
<url>
 <loc>http://www.example.com/video.html</loc>
 <lastmod>2016-06-01T14:05:05Z</lastmod>
 <xhtml:link href="http://www.example.de/index.html" hreflang="de" media="only screen and (max-width: 640px)" rel="alternate nofollow"/>
</url>

Look at Alternate Links as required.

Geo Sitemaps

defmodule Sitemaps do
  use Sitemap, compress: true, host: "http://example.com"

  def generate do
    create do
      add "geo.html", alternates: [
           format: "kml"
         ]
    end
  end
end
Generated Result
<url>
 <loc>http://www.example.com/geo.html</loc>
 <lastmod>2016-06-01T14:15:25Z</lastmod>
 <geo:geo>
   <geo:format>kml</geo:format>
 </geo:geo>
</url>

Look at Geo Sitemaps as required.

Mobile Sitemaps

defmodule Sitemaps do
  use Sitemap, compress: true, host: "http://example.com"

  def generate do
    create do
      add "mobile.html", priority: 0.5, changefreq: "hourly", mobile: true
    end
  end
end
Generated Result
<url>
 <loc>http://www.example.com/mobile.html</loc>
 <lastmod>2016-06-01T14:24:44Z</lastmod>
 <changefreq>hourly</changefreq>
 <priority>0.5</priority>
 <mobile:mobile/>
</url>

Look at Mobile Sitemaps as required.

PageMap sitemap

defmodule Sitemaps do
  use Sitemap, compress: true, host: "http://example.com"

  def generate do
    create do
      add "pagemap.html", pagemap: [
        dataobjects: [[
          type: "document",
          id: "hibachi",
          attributes: [
            [name: "name",   value: "Dragon"],
            [name: "review", value: "3.5"],
          ]
        ]]
      ]
    end
  end
end
Generated Result
<url>
 <loc>http://www.example.com/pagemap.html</loc>
 <lastmod>2016-06-02T17:01:17Z</lastmod>
 <PageMap>
   <DataObject id="hibachi" type="document">
     <Attribute name="name">Dragon</Attribute>
     <Attribute name="review">3.5</Attribute>
   </DataObject>
 </PageMap>
</url>

Look at PageMap sitemap as required.

Additional links into the Sitemap Index

create do
  add_to_index "/mysitemap1.xml.gz"
  add_to_index "/alternatemap.xml"
  add_to_index "/changehost.xml.gz", host: "http://something.com"

  add ...
  add ....
end
<?xml version='1.0' encoding='utf-8'?>
<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
 <sitemap>
   <loc>http://example.com/mysitemap1.xml.gz</loc>
   <lastmod>2017-05-19T11:42:45+09:00</lastmod>
 </sitemap>
 <sitemap>
   <loc>http://example.com/mysitemap2.xml.gz</loc>
   <lastmod>2017-05-19T11:42:45+09:00</lastmod>
 </sitemap>
 <sitemap>
   <loc>http://something.com/changehost.xml.gz</loc>
   <lastmod>2017-05-19T11:42:45+09:00</lastmod>
 </sitemap>
 <sitemap>
   <loc>http://example.com/sitemap1.xml.gz</loc>
   <lastmod>2017-05-19T11:42:45+09:00</lastmod>
 </sitemap>
</sitemapindex>

Known issue

Inspired by

More Repositories

1

go-sitemap-generator

go-sitemap-generator is the easiest way to generate Sitemaps in Go
Go
217
star
2

phoenix_html_simplified_helpers

Some helpers for phoenix html( truncate, time_ago_in_words, number_with_delimiter, url_for, current_page? )
Elixir
31
star
3

beego-samples

auth
Go
28
star
4

esx

A client for the Elasticsearch with Ecto, written in Elixir
Elixir
28
star
5

tastypie-queryset-client

Client for Tastypie. Provide operation similar to the Django Model API .
Python
16
star
6

social-bookmark-counter-on-google-search

https://github.com/ikeikeikeike/bookmarkhub
JavaScript
14
star
7

exkanji

A Elixir library for translating between hiragana, katakana, romaji, kanji and sound. It uses Mecab.
Elixir
13
star
8

sitesx

A Phoenix SubDomainer which makes subdomain using DigitalOcean, Cloudflare, etc. API and contains convenient view helper interface along with Plug and Ecto.
Elixir
10
star
9

django-spine

Spine plugin for Django
Python
10
star
10

bing_translator

A simple Elixir interface to Bing's translation API.
Elixir
9
star
11

celery-tracker

Receive/Sending event tracking data for the celery.
Python
9
star
12

bookmarkhub

https://github.com/ikeikeikeike/social-bookmark-counter-on-google-search
CoffeeScript
9
star
13

fluent-plugin-gstore

Google Cloud Storage, Fluentd Plugin.
Ruby
8
star
14

exromaji

A Elixir library for translating between hiragana, katakana, romaji and sound.
Elixir
8
star
15

exfavicon

Elixir library for discovering favicons
Elixir
7
star
16

pongor

Go
4
star
17

gopkg

thats convenient
Go
4
star
18

scrivener_esx

pagination
Elixir
3
star
19

scrapy-proxies

proxy utility
Python
3
star
20

python-eco

Python Eco Compiler
Python
3
star
21

django-impala-backend

Unofficial impala backend package for Django.
Python
3
star
22

common_device_detector

Detect devices that desktop, mobile, smartphone and tablet form User Agent.
Elixir
3
star
23

cheapcdn

CDN Material
Go
3
star
24

rsyslog-monitor

search In realtime - from a browser.
2
star
25

gocore

This is common package powered by https://github.com/uber-go/dig dependency injection toolkit.
Go
2
star
26

extoon

Elixir
2
star
27

django-subcommand

Add sub command to The Django manage command.
Python
2
star
28

wakaway

There're ยงWalker's Alias Methodยง and ยงWeighted Choiceยง that providing weighted random choice algorism in two ways.
Elixir
2
star
29

godic

Base code for Git based wiki like a Encyclopedia (named dic subdomain) service in japan.
CSS
2
star
30

exmail

Email Delivery, Admin, Analyzer For Marketing
Elixir
2
star
31

redisank

A common ranking system on Redis with Plug.
Elixir
2
star
32

cheapcdn-ansible

CDN Material
2
star
33

exantenna

Elixir
2
star
34

dotfiles

Python
2
star
35

rdtype

Calling Redis Data Types in easily way.
Elixir
2
star
36

somequeue

Operate some queue system through sidekiq interface
Ruby
2
star
37

packer-ubuntu-12.04.3

For Virtualbox. Next: https://github.com/ikeikeikeike/vagrant-rbenv-virtualenv
Shell
2
star
38

go-googleimages

Google Image Search API (Deprecated) for Go
Go
2
star
39

beego-loggers

ses,mailcatcher
Go
1
star
40

hubot-sarcasmlink

Sarcasm link for hubot.
CoffeeScript
1
star
41

scrape-django-app

for example as a django application
Python
1
star
42

boot-ads-k8s

Shell
1
star
43

peerdrive

[WIP] Some of them synchronization by tiny code.
Go
1
star
44

vpn-mesh

Fuzzy VPN Mesh by tiny code.
Go
1
star
45

drone-rb

1
star
46

elle-k8s

Shell
1
star
47

docker-bastion

Dockerfile
1
star
48

drone-py

Python
1
star
49

wrapped-maps-jquery

A jQuery plugin for Google maps api v3.
CoffeeScript
1
star
50

prototype

Go
1
star
51

ikeikeikeike

1
star
52

speech-to-text

Dockerfile
1
star
53

rust-gqls

Rust GraphQL MySQL Diesel
Rust
1
star
54

panglao-scraper

CDN Material
Python
1
star
55

panglao

Elixir
1
star
56

charneoapo

Go
1
star
57

shuffler

Go
1
star
58

clustertransport-base

Message passing based client(transport) on cluster systems.
Go
1
star
59

boot-ads

Kotlin
1
star
60

lit-k8s

Shell
1
star
61

lit-terraform

HCL
1
star
62

speech_to_text_app

Dart
1
star
63

drone-ex

1
star
64

gocuration

Go
1
star
65

mad

scientist
Go
1
star
66

gocuration-api

Go
1
star
67

panglao-elixir

Client for panglao api
Elixir
1
star
68

go-scrap

Go
1
star
69

JapaneseTag

้ฌผ
Objective-C
1
star
70

analytics-counter

Availability by Scrapy.
Python
1
star
71

martini-contrib

thats convenient
Go
1
star
72

ex_edited

Elixir
1
star
73

drone-scala

1
star
74

scrapy-2ch-summary-spiders

heh
Python
1
star
75

docker-sbt

1
star
76

terraform-starterkit

HCL
1
star
77

cheapcdn-terraform

CDN Material
HCL
1
star
78

ansible-playbooks

my playbooks for Ubuntu
1
star
79

boot-ads-admin

Python
1
star
80

ikeikeikeike.github.com

posterous
1
star
81

vectags

for virtual environment.
JavaScript
1
star
82

rust-gql

Rust GraphQL MySQL Simple
Rust
1
star
83

Camotes-iOS

Swift
1
star
84

go-apiactress

apiactress for Go
Go
1
star
85

coffee-serializers

Serializers for CoffeeScript.
CoffeeScript
1
star
86

memdtest

There's golang for testing with memcached that concerns a own personally.
Go
1
star
87

elle-terraform

HCL
1
star
88

ddrive

1
star
89

seg-test

Dockerfile
1
star
90

seread-sample

1
star
91

encoding-base94

Radix Conversion
Go
1
star
92

my-deps

1
star
93

my-deps-pipenv

1
star
94

ansible-playbook

custom roles
Ruby
1
star
95

skeleton-web

npm typescript webworker
JavaScript
1
star
96

boot-ads-terraform

HCL
1
star
97

docker-golang

1
star
98

drone-go

1
star
99

eck-ja-small

cloud-on-k8s no password
1
star
100

exblur

its f
Elixir
1
star