Build task removes unrelated file

I’m using Github pages to host my middleman server. It is working great!

I’m running into a problem, however. I’ve added a CNAME for my site, which on Github means that a CNAME file is created by Github in the root of the HTML structure.

When I run bundle exec middleman build the site builds, however, the CNAME file Github had added gets deleted.

$ bundle exec middleman build
      ...
      create  build/index.html
      remove  build/CNAME

How can I configure middleman to ignore this file and not delete it? Right now I just reset the file every time I commit… which is very error prone.

It does look like I can use bundle exec middleman build --no-clean to prevent cleaning of files. This will result in old/un-used files from potentially making it into the build, but that is better than resetting the file in git on every build/commit.

A better fix looks like I can just create the CNAME file in my source directory, and it will get copied over. Leaving this post up for anyone who runs into it later.

Yes, all static cruft like favicon.ico, BingSiteAuth.xml or robots.txt should be put in source and they will be copied-over to build.

As a sidenote, if you’re using the google-site-verification HTML files and middleman-search_engine_sitemap extension, you don’t want your verification file to be added to sitemap. So add .erb extension to your google6d4x95dxedfed4x1.html file and add a proper frontmatter to it, like:

---
hide_from_sitemap: true
---

google-site-verification: google6d4x95dxedfed4x1.html