2017-05-09 94 views
0

Middleman可以在其配置URL下show a sitemap。將靜態網站發佈到CDN時,我無法找到訪問此網站地圖的信息,並且希望將其用於搜索引擎優化目的。到目前爲止,我已經假設中間人在構建中包含站點地圖,但現在我看不到它。假設這是事實,我如何在線發佈網站地圖?在本地服務器運行時,Middleman的站點地圖

回答

1

雖然我是一個Middleman新手,並沒有到處爲我的Middleman網站添加一個網站地圖,我的朋友使用Middleman Search Engine Sitemap gem to generate a sitemap in his sites

,我已經看到了另一種解決方案是use a Builder file生成網站地圖:

創建一個源文件:source/sitemap.xml.builder

xml.instruct! 
xml.urlset 'xmlns' => "http://www.sitemaps.org/schemas/sitemap/0.9" do 
    sitemap.resources.select { |page| page.destination_path =~ /\.html/ && page.data.noindex != true }.each do |page| 
    xml.url do 
     xml.loc URI.join(settings.casper[:blog][:url], page.destination_path) 
    last_mod = if page.path.start_with?('articles/') 
     File.mtime(page.source_file).to_time 
     else 
     Time.now 
     end 
     xml.lastmod last_mod.iso8601 
     xml.changefreq page.data.changefreq || "monthly" 
    xml.priority page.data.priority || "0.5" 
    end 
end 
end 
+0

非常感謝!起初,我發現[這個寶石](https://github.com/statonjr/middleman-sitemap)(它有更好的SEO),但它在目前的中間商中被打破了。然後我找到了建造者,但不知道其他的寶石。我會嘗試包括,以便簡化的事情。 –

相關問題