Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Sitemap is the easiest way to generate Sitemaps in Elixir.

License

NotificationsYou must be signed in to change notification settings

ikeikeikeike/sitemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusHex versionHex downloadsInline docshex.pm

Generating sitemap.xml

Installation

Ifavailable in Hex, the package can be installed as:

  1. Add sitemap to your list of dependencies inmix.exs:
defdepsdo[{:sitemap,"~> 1.1"}]end
  1. Ensure sitemap is started before your application:
defapplicationdo[extra_applications:[:sitemap]]end

Usage

sitemap helps you define a module with agenerate function which will build a sitemap for your site. You must decide how to callgenerate - 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 awrite/2 function and persist the sitemaps wherever you like.

Basic
defmoduleSitemapsdouseSitemapdefgeneratedocreatedo# list each URL that should be includedadd"path1",priority:0.5,changefreq:"hourly",expires:nil,mobile:true# ...end# notify search engines (currently Google and Bing) of the updated sitemapping()endend
With Phoenix
defmoduleSitemapsdoaliasMyAppWeb.{Endpoint,Router.Helpers}useSitemap,host:"http://#{Application.get_env(:myapp,Endpoint)[:url][:host]}",files_path:"priv/static/sitemaps/",public_path:"sitemaps/"defgeneratedocreatedo# list each URL that should be included, using your application's routesaddHelpers.entry_path(Endpoint,:index),priority:0.5,changefreq:"hourly",expires:niladdHelpers.entry_path(Endpoint,:about),priority:0.5,changefreq:"hourly",expires:nil# ...end# notify search engines (currently Google and Bing) of the updated sitemapping()endend

Ways to set sitemap's options

Set options via theuse statement
defmoduleSitemapsdouseSitemap,compress:false,host:"http://example.com"defgeneratedocreatedoadd"path1",priority:0.5,changefreq:"hourly"add"path2",priority:0.5,changefreq:"hourly"endping()endend
Set options via arguments tocreate
defmoduleSitemapsdouseSitemapdefgeneratedocreatecompress:false,host:"http://example.com"doadd"path1",priority:0.5,changefreq:"hourly"add"path2",priority:0.5,changefreq:"hourly"endping()endend
Set options viaMix config
useMix.Configconfig:sitemap,[compress:false,host:"http://example.com",]
Set options via environment variables
SITEMAP_COMPRESS=false SITEMAP_HOST=http://example.commixrun./sitemap.exs

And you guys should follow mix task documents, here:

Available options
NameDefault ValueEnvironment-
max_sitemap_files10000SITEMAP_MAXFILESMax sitemap links per index file
max_sitemap_links10000SITEMAP_MAXLINKSMax links per sitemap
max_sitemap_news1000SITEMAP_MAXNEWSMax news sitemap per index_file
max_sitemap_images1000SITEMAP_MAXIMAGESMax images per url
max_sitemap_filesize5000000SITEMAP_MAXFILESIZEBytes
hosthttp://www.example.comSITEMAP_HOSTYour domain, also host with http scheme.
filenamesitemapSITEMAP_FILENAMEName of sitemap file.
files_pathsitemapSITEMAP_SITEMAPS_PATHAfter domain path's location on URL.
public_pathsitemapSITEMAP_PUBLIC_PATHWrite sitemap files to this local path.
adapterSitemap.Adapters.FileSITEMAP_ADAPTERYou'd change to write each filesystem
verbosetrueSITEMAP_VERBOSEGetting more information in sitemap working.
compresstrueSITEMAP_COMPRESSGzip compression.
create_indexautoSITEMAP_CREATE_INDEXGenerating sitemps to this directory path.

Features

Current Features or To-Do

Supports: generate kind of some sitemaps

News Sitemaps

defmoduleSitemapsdouseSitemap,compress:false,host:"http://example.com"defgeneratedocreatedoadd"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"]endendend
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 atCreating a Google News Sitemap as required.

Image sitemaps

defmoduleSitemapsdouseSitemap,compress:false,host:"http://example.com"defgeneratedocreatedoadd"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",]endendend
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 atImage sitemaps as required.

Video sitemaps

defmoduleSitemapsdouseSitemap,compress:true,host:"http://example.com"defgeneratedocreatedoadd"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]endendend
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_locallow_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_loctitle="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:restrictionrelationship="allow">IE GB US CA</video:restriction>   <video:uploaderinfo="http://www.example.com/users/grillymcgrillerson">GrillyMcGrillerson</video:uploader>   <video:pricecurrency="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 atVideo sitemaps as required.

Alternate Links

defmoduleSitemapsdouseSitemap,compress:true,host:"http://example.com"defgeneratedocreatedoadd"index.html",alternates:[href:"http://www.example.de/index.html",lang:"de",nofollow:true,media:"only screen and (max-width: 640px)"]endendend
Generated Result
<url> <loc>http://www.example.com/video.html</loc> <lastmod>2016-06-01T14:05:05Z</lastmod> <xhtml:linkhref="http://www.example.de/index.html"hreflang="de"media="only screen and (max-width: 640px)"rel="alternate nofollow"/></url>

Look atAlternate Links as required.

Geo Sitemaps

defmoduleSitemapsdouseSitemap,compress:true,host:"http://example.com"defgeneratedocreatedoadd"geo.html",alternates:[format:"kml"]endendend
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 atGeo Sitemaps as required.

Mobile Sitemaps

defmoduleSitemapsdouseSitemap,compress:true,host:"http://example.com"defgeneratedocreatedoadd"mobile.html",priority:0.5,changefreq:"hourly",mobile:trueendendend
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 atMobile Sitemaps as required.

PageMap sitemap

defmoduleSitemapsdouseSitemap,compress:true,host:"http://example.com"defgeneratedocreatedoadd"pagemap.html",pagemap:[dataobjects:[[type:"document",id:"hibachi",attributes:[[name:"name",value:"Dragon"],[name:"review",value:"3.5"],]]]]endendend
Generated Result
<url> <loc>http://www.example.com/pagemap.html</loc> <lastmod>2016-06-02T17:01:17Z</lastmod> <PageMap>   <DataObjectid="hibachi"type="document">     <Attributename="name">Dragon</Attribute>     <Attributename="review">3.5</Attribute>   </DataObject> </PageMap></url>

Look atPageMap sitemap as required.

Additional links into the Sitemap Index

createdoadd_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'?><sitemapindexxmlns: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

About

Sitemap is the easiest way to generate Sitemaps in Elixir.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp