Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

auto sitemap generation in middleman

Notifications You must be signed in to change notification settings

pixelpark/middleman-sitemap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

middleman-sitemap

Howto auto sitemap generation in middleman.

First of all, you need to have the builder gem installed. You can do this via console:

gem install builder

or add to your Gemfile:

gem "builder"

in your config.rb you need to require 'builder',

require 'builder'

and remove the layout from your sitemap.xml via:

page "/sitemap.xml", :layout => false

Next, create a sitemap.yml file in your data folder with this content:

url: http://localhost:4567

and replace the url with your domain.

+Next, copy the sitemap.xml.builder in this repo to your project root folder. Now, start your middleman server, and take a look at http://localhost:4567/sitemap.xml

To override the default changefreq and priority values adding the corresponding local yaml data to the page:

---
changefreq: "weekly"
priority: "1"
---

html sitemap

If you need a sitemap or list of all your middleman pages, then you create a sitemap.html.erb with the following content:

<% root_url = data.sitemap.url %>
<ul>
    <% sitemap.resources.each do |page| %>
        <% if page.url =~ /\.html/ %>
            <li><a href="<%= "#{root_url}#{page.url}" %>"><%= "#{root_url}#{page.url}" %></a></li>
        <% end %>
    <% end %>
</ul>

If you don't wanna have layout at this page, don't forget to add:

page "/sitemap.html", :layout => false

to your config.rb.

About

auto sitemap generation in middleman

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published