title: Using Frontmatter with Dynamic Pages in Middleman 4
body: <p>I have spent ample time researching this without finding a solution that worked. I would love it if someone could help me figure this out.</p>
  
  <p>I’m trying to use Dynamic Pages in my setup, but need to include dynamic Frontmatter with this. But I can’t use Frontmatter in the template file, so I was thinking I could use a YAML data file instead? I tried various approaches, but none were successful. The dynamic pages load just fine, but every one of them will use the same Frontmatter unless I can pull in dynamic data instead.</p>
  
  <p>My config includes:</p>
  
  <pre><code>["england", "france"].each do |team|
    proxy "/teams/#{team}/index.html", "/teams/team.html", :locals =&gt; { :team_name =&gt; team }, :ignore =&gt; true
  end
  </code></pre>
  
  <p>And my directory structure in this section looks like this:</p>
  
  <pre><code>teams
  - index.html.erb
  - team.html.erb
  </code></pre>
  
  <p>I began a YAML data file that includes:</p>
  
  <pre><code>england:
    title: "Teams/England"
    description: "England"
    headline: "England"
    addclass: "england cols"
  france:
    title: "Teams/France"
    description: "France"
    headline: "France"
    addclass: "france cols"
  </code></pre>
  
  <p>When I use the aforementioned data in the template file as Frontmatter, it works just fine:</p>
  
  <pre><code>---
  title: Teams/France
  description: France
  headline: France
  addclass: france cols
  ---
  </code></pre>
  
  <p>One example of how I am using the data:</p>
  
  <p><code>&lt;%= current_page.data.addclass %&gt;</code></p>
  
  <p>My questions are as follows:</p>
  
  <ol>
  <li>How can I use a YAML data file to serve unique data to each Dynamic Page?</li>
  <li>Can I use the final URI segment ( “england” from /teams/england/, “france” from /teams/france/, etc.) to define which data set to use?</li>
  <li>Can I do this without impacting other non-dynamic-pages (/matches/, /groups/, etc.) on the site?</li>
  </ol>
  
  <p>Thank you so very much in advance.</p>