toto
toto copied to clipboard
Sitemap?
Is anyone working on a sitemap implementation for Toto? If not, any pointers on extensibility points one might leverage?
For anyone else that may be confused by this, adding a templates/sitemap.builder file isn't enough - you also need to add a templates/pages/sitemap.rhtml. Once you have BOTH, you can access /sitemap (for HTML version) and /sitemap.xml.
This could probably be documented somewhere if it's intended behavior.
This is not intended behaviour. I've made a fix, you can pull it from http://github.com/cloudhead/toto/pull/58
http://artemk.name/2011/06/01/sitemap-in-toto/
I believe it's better to have this feature (I like the code of artemk) in Rakefile of dorothy.
i think this is not supported any more. If you need sitemap, just add this by hands.
I tried manually adding a sitemap.xml in the public folder; but toto returns a 404. How can I have this page accessible?
@benjamincharity add it to the list of files served by Rack::Static. Replace this block in your config.ru file:
# Rack config
use Rack::Static, {
:urls => %w{/css /js /i /favicon.ico /fonts /robots.txt /humans.txt},
:root => 'public'
}
with
# Rack config
use Rack::Static, {
:urls => %w{/css /js /i /favicon.ico /fonts /robots.txt /humans.txt /sitemap.xml},
:root => 'public'
}
Oh my gosh. I can't believe I forgot that.
Definitely time to get some sleep.
Thanks!
Sitemap generation for toto is in fact as easy as simple Rake task:
BLOG_URL = "http://blog.ixti.net/"
desc "Rebuild sitemap"
task :sitemap do
xml = Builder::XmlMarkup.new(:indent => 2)
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
xml.url do
xml.loc BLOG_URL
xml.lastmod "2005-01-01"
xml.changefreq "weekly"
xml.priority 0.8
end
archived = Time.new - (365 * 24 * 60 * 60)
Toto::Site.new(Toto::Config::Defaults).archives.delete(:archives).each do |article|
d, m, y = article.date.split "/"
xml.url do
xml.loc "#{BLOG_URL}#{article.path.slice(1..-1)}"
xml.lastmod "#{y}-#{m}-#{d}"
xml.changefreq (Time.new(y, m, d) < archived) ? "never" : "monthly"
end
end
end
File.open "sitemap.xml", "w+" do |f|
f.puts xml.target!
end
end
Here's live example: https://github.com/ixti/blog/blob/master/Rakefile
Hmm I run that and it only returns the index page:
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://benjamincharity.com/</loc>
<lastmod>2005-01-01</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
</urlset>
The sitemap portion of my rakefile looks like this:
BLOG_URL = "http://benjamincharity.com/"
desc "Rebuild sitemap"
task :sitemap do
xml = Builder::XmlMarkup.new(:indent => 2)
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
xml.url do
xml.loc BLOG_URL
xml.lastmod "2005-01-01"
xml.changefreq "weekly"
xml.priority 0.8
end
archived = Time.new - (365 * 24 * 60 * 60)
Toto::Site.new(Toto::Config::Defaults).archives.delete(:archives).each do |article|
d, m, y = article.date.split "/"
xml.url do
xml.loc "#{BLOG_URL}#{article.path.slice(1..-1)}"
xml.lastmod "#{y}-#{m}-#{d}"
xml.changefreq (Time.new(y, m, d) < archived) ? "never" : "monthly"
end
end
end
File.open "public/sitemap.xml", "w+" do |f|
f.puts xml.target!
end
end
Hm... Probably my branch of toto works with archives a little bit different way. Will recheck and let you know possible fi for your blog.
First of all i have a small typos in my Rakefile :)) So you can resync with latest version of it :))
But the problem was not with rake task. You have custom extension of files markdown
, so in order to make it work work you need something like this:
config = Toto::Config::Defaults
config[:ext] = 'markdown'
Toto::Site.new(config).archives.delete(:archives).each do |article|
# ...
end
Or, if you'll reuse my latest version, just alter something right over 6th line:
$config = Toto::Config::Defaults
$config[:ext] = 'markdown'
$editor = ENV['EDITOR'] || ""