hsmicon
./

Computer-Heimwerker*

*gedanken.konzepte.projekte

In Octopress automatisch sitemap.xml versenden und Blogdienste anpingen

Mit rake gen_deploy sitemap an google und bing senden sowie Blogdienste nach Veröffentlichung automatisch anpingen

Wer wie ich Octopress bzw. Jekyll nutzt und seine Website auf einem Apache-Server bei einem neuen Beitrag über rsync mittels rake deploy aktualisiert, hat es mit folgender Anleitung einfacher.

Mit dem Befehl rake gen_deploy wird folgendes aufeinmal erledigt (Stapelverarbeitung):

  1. rake integrate : Alle mit rake isolate versteckten Posts zurück in posts-Ordner
  2. rake generate: Website generieren
  3. rake deploy: Website mittels rsync/ssh (in meinem Fall) auf Apache-Webserver hochladen
  4. rake pingomatic: Pingomatic über XML-RPC anpingen, um neuen Post anzukündigen
  5. rake sitemapgoogle: Google.com neue sitemap.xml schicken
  6. rake sitemapbing: Bing.com neue sitemap.xml schicken

Schritt 1: Pings einbinden

Dafür muss man zunächst im Ordner octopress im Ruby-Script Rakefile folgenden Code (z.B. an das Ende) einfügen:

[Rakefile]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## Notify pingomatic, google, bing
## Code according to http://seraphyn.teiko.org/archives/octopress-rakefile.html
desc 'Ping pingomatic'
task :pingomatic do
  begin
    require 'xmlrpc/client'
    puts '* Pinging ping-o-matic'
    XMLRPC::Client.new('rpc.pingomatic.com', '/').call('weblogUpdates.extendedPing', 'DeinBlogTitel' , 'http://deineblogdomain.tld', 'http://deineblogdomain.tld/atom.xml')
  rescue LoadError
    puts '! Could not ping ping-o-matic, because XMLRPC::Client could not be found.'
  end
end

desc 'Ping bloggerei'
task :pingbloggerei do
  begin
    require 'xmlrpc/client'
    puts '* Pinging bloggerei'
    XMLRPC::Client.new('http://rpc.bloggerei.de/ping', '/').call('weblogUpdates.extendedPing', 'DeinBlogTitel' , 'http://deineblogdomain.tld', 'http://deineblogdomain.tld/atom.xml')
  rescue LoadError
    puts '! Could not ping bloggerei, because XMLRPC::Client could not be found.'
  end
end

desc 'Notify Google of the new sitemap'
task :sitemapgoogle do
  begin
    require 'net/http'
    require 'uri'
    puts '* Pinging Google about our sitemap'
    Net::HTTP.get('www.google.com', '/webmasters/tools/ping?sitemap=' + URI.escape('http://deineblogdomain.tld/sitemap.xml'))
  rescue LoadError
    puts '! Could not ping Google about our sitemap, because Net::HTTP or URI could not be found.'
  end
end

desc 'Notify Bing of the new sitemap'
task :sitemapbing do
  begin
    require 'net/http'
    require 'uri'
    puts '* Pinging Bing about our sitemap'
    Net::HTTP.get('www.bing.com', '/webmaster/ping.aspx?siteMap=' + URI.escape('http://deineblogdomain.tld/sitemap.xml'))
  rescue LoadError
    puts '! Could not ping Bing about our sitemap, because Net::HTTP or URI could not be found.'
  end
end

Anschließend muss in diesem Code Folgendes an Ihren Blog angepasst werden:

  • 2x: DeinBlogTitel: Bei mir wäre das z.B.: Computer-Heimwerker-Blog
  • 6x: http://deineblogdomain.tld: Bei mir wäre das z.B.: http://home-server-mind.com

Schritt 2: Stapelverarbeitung einrichten

Um mit dem Befehl gen_deploy wie oben beschrieben mit der Veröffentlichung alles auf einmal zu erledigen, muss man in der gleichen Rakefile die Zeile mit dem Inhalt

    task :gen_deploy => [:integrate, :generate]

finden und hiermit ersetzen:

[Rakefile]
1
task :gen_deploy => [:integrate, :generate, :deploy, :pingomatic, :sitemapgoogle, :sitemapbing ]

Weiterführende Literatur: XML-RPC | Was sind Sitemaps | Sitemap mittels HTTP-Anforderung an Google | Ruby rake | Serphyn Blog

Fertig. Ich freue mich über Feedback.

Kommentare

(Datenschutzerklärung und Nutzungsbedingungen)