Copying extra files into the directory you publish

Surge will only read and publish the files in the directory that you pass to the command line tool. Most static site generators will automatically copy the files from your source directory into the directory you will want to publish, like a CNAME file or .surgeignore.

Some static site generators or tools like Yeoman or Grunt, however, may need you to explicitly move these files into the directory you publish. Here’s how you can copy an additional file—the CNAME file in these examples—into the directory you want to publish, depending on the tool you’re using.

Copying files with Grunt

With Grunt, use grunt-contrib-copy, for example:


  // …
  copy: {
    main: {
      src: './src/CNAME',
      dest: './dest/'

Copying files with Gulp

With Gulp, you can copy over individual files, or the entire source folder, for exmaple:

gulp.src(['./src/CNAME'])     // Source file
  .pipe(gulp.dest('./build')) // Output

Copying files with npm and mv

When using npm run scripts as your build tool, you can add an npm run script that will automatically move your CNAME file or other folder from one directory to another:

"scripts": {
  "move": "mv ./src/CNAME ./build/"
  // Etc.

You may want to run this command automatically when you deploy, which is possible using npm pre- and post-run scripts.

Copying files with other tools

Other static site generators will often copy files over for you, or provide some other option or plugin to enable this. If you’re stuck or have more questions, feel free to join our chat, or mention @surge_sh on Twitter.