1

I am creating a New Middleman website for the first time. I have roughly 20,000 pages I would like to make static and I am nearly there except for this 1 glooming problem. I have a CSV file that is produced monthly that I will convert to yaml.

The structure I have is identical to below: data/people.yml (code from middleman website)

friends:
  -
    name: Bob Smith
    address: 101 Foo Lane
    birth: 1966-03-03
  -
    name: Mary Johnson
    address: 120 Bar St
    birth: 1967-06-18

I can loop through without a hitch using the below code:

<% data.people.friends.each do |f| %>
<%= f.name %><br/>
<%= f.address %><br/>
<%= f.birth %><br/><br/>
<% end %>

Which produces:

Bob Smith
101 Foo Lane
1966-03-03

Mary Johnson
120 Bar St
1967-06-18

The goal for me here is to have just Bob's information when the user goes to http://www.web_site_here.com/people/bob.html etc.,

I've tried several methods like the one below, with no luck.

<% data.people.friends.each do |name, person| %>
   <%= person.name %>
<% end %>
Pilot
  • 11
  • 2

1 Answers1

0

You will need to create proxy pages for each person. See the example here https://middlemanapp.com/advanced/dynamic-pages/.

You create a template (e.g. person.html.erb) which just shows one persons information e.g.

<%= f.name %><br/>
<%= f.address %><br/>
<%= f.birth %><br/><br/>

Then in your config.rg you loop through the people and create a dynamic page for each person using that template and the yaml data.

data.people.friends.each do |f|
    proxy "/people/#{f.name}.html", "/person.html", :locals => { :f => f }
end
Gerard Condon
  • 761
  • 1
  • 7
  • 22