I'm getting "You must either specify the blog name in calling this method or in your page frontmatter (using the 'blog' blog_name)" when building --verbose, but not when running middleman

So I’m having an issue where I get the following error when I run middleman build

       error  build/partials/marketing/loop/index.html
You must either specify the blog name in calling this method or in your page frontmatter (using the 'blog' blog_name)
...
...
...

When I run middleman I do not get any errors.

I have several blogs that are set up as such:

blogone.html.erb

---
title: Blog One
blog: blogone
---
<% blog.articles.each do |article| %>
    <li><a href="<%= article.url %>"><%= article.title %></a></li>
<% end %>

blogone/content.md

---
title: Content One
---
...

blogtwo.html.erb

---
title: Blog Two
blog: blogtwo
---
<% blog.articles.each do |article| %>
    <li><a href="<%= article.url %>"><%= article.title %></a></li>
<% end %>

blogtwo/content.md

---
title: Content two
---
...

config.rb

# Blog One
activate :blog do |blog|
  blog.name = "blogone"
  blog.prefix = "blogone"
  blog.permalink = "{title}.html"
  blog.sources = "{year}-{month}-{day}-{title}.html"
  blog.layout = "layout_article"
end

# Blog Two
activate :blog do |blog|
  blog.name = "blogtwo"
  blog.prefix = "blogtwo"
  blog.permalink = "{title}.html"
  blog.sources = "{year}-{month}-{day}-{title}.html"
  blog.layout = "layout_article"
end

Now the built site actually works fine. However my CI tool doesn’t pass and therefore doesn’t deploy because the build fails. So I need to figure this out.

Ok so I figured it out.

I had my blog loop in a separate partial. I wanted me to include the front-matter in the partial on build because it attempts to create an index.html file from it. This seems like odd behavior. To better clarify, I have:

blogone/index.html.erb

---
title: Blog One
blog: blogone
---
<%= partial "partials/blogone/loop" %>

partials/blogone/loop.erb

<% blog.articles.each do |article| %>
    <li><a href="<%= article.url %>"><%= article.title %></a></li>
<% end %>

^^ That resulted in the error. When the middleman server is run the files are combined so I didn’t get the error. However when you build middleman creates a file at partials/blogone/loop/index.html. That seems odd to me. So the solution was to add front-matter to the loop partial.

All partials should have an _ before them …

Therefore would not be built