HandyOrg/HandyControl · warning

Include file empty.

Error message

Include file empty.

What it means

The NexT theme's include-raw Hexo tag reads a file and logs a warning when fs.readFile returns empty/null contents. The file exists (the not-found branch already returned), but it has zero bytes, so nothing is included in the rendered output. Non-fatal: the tag simply returns nothing.

Solutions

  1. Put the intended content into the referenced file.
  2. Verify the resolved path points to the file you meant (an empty unintended file may shadow the real one).
  3. If an empty file is intentional, ignore the warning or populate a minimal placeholder.

Example fix

// before
{% include-raw lang:javascript %}   // scripts/demo.js exists but is 0 bytes
// after
// add content to scripts/demo.js, e.g.:
// console.log('demo');
{% include-raw lang:javascript %}
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
function canIncludeRaw(p) {
  if (!fs.existsSync(p)) { console.error('include-raw: file not found: ' + p); return false; }
  if (fs.statSync(p).size === 0) { console.warn('include-raw: file is empty: ' + p); return false; }
  return true;
}

Type guard

function isNonEmptyFile(stat) {
  return stat && stat.isFile() && stat.size > 0;
}

Prevention

When it happens

Trigger: {% include-raw path %} where the referenced file exists on disk but is completely empty (0 bytes), so contents is falsy in the readFile then-callback.

Common situations: An empty placeholder file committed to the repo, a build/export step that truncated the file, or a shared code snippet file that was emptied during a refactor.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14). Data as JSON: /api/errors/d8bef89239fc309f. Report an issue: GitHub.

Appendix: source

Thrown at doc/themes/next/scripts/tags/include-raw.js:22

/* global hexo */

'use strict';

var pathFn = require('path');
var fs = require('hexo-fs');

function includeRaw(args) {
  var path = pathFn.join(hexo.source_dir, args[0]);

  return fs.exists(path).then(function(exist) {
    if (!exist) {
      hexo.log.error('Include file not found!');
      return;
    }
    return fs.readFile(path).then(function(contents) {
      if (!contents) {
        hexo.log.warn('Include file empty.');
        return;
      }
      return contents;
    });
  });
}

hexo.extend.tag.register('include_raw', includeRaw, {ends: false, async: true});

View on GitHub (pinned to 2c0875ebd6)