{"record":{"id":"61d1e167023b384f","repo":"hexojs/hexo","slug":"invalid-config-detected-root-should-not-be-empt","errorCode":null,"errorMessage":"Invalid config detected: \"root\" should not be empty!","messagePattern":"Invalid config detected: \"root\" should not be empty!","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"critical","filePath":"lib/hexo/validate_config.ts","lineNumber":26,"sourceCode":"  log.info('Validating config');\n\n  // Validation for config.url && config.root\n  if (typeof config.url !== 'string') {\n    throw new TypeError(`Invalid config detected: \"url\" should be string, not ${typeof config.url}!`);\n  }\n  try {\n    // eslint-disable-next-line no-new\n    new URL(config.url);\n    assert(new URL(config.url).protocol.startsWith('http'));\n  } catch {\n    throw new TypeError('Invalid config detected: \"url\" should be a valid URL!');\n  }\n\n  if (typeof config.root !== 'string') {\n    throw new TypeError(`Invalid config detected: \"root\" should be string, not ${typeof config.root}!`);\n  }\n  if (config.root.trim().length <= 0) {\n    throw new TypeError('Invalid config detected: \"root\" should not be empty!');\n  }\n\n  if (!config.timezone) {\n    log.warn('No timezone setting detected! Using LocalTimeZone as the default timezone.');\n    log.warn('This behavior will be changed to UTC in the next major version. Please set timezone explicitly (e.g. LocalTimeZone or America/New_York) in _config.yml to avoid this warning.');\n  } else {\n    const configTimezone = moment.tz.zone(config.timezone);\n    if (!configTimezone) {\n      log.warn(\n        `Invalid timezone setting detected! \"${config.timezone}\" is not a valid timezone.`\n      );\n    } else {\n      const machineTimezone = moment.tz.guess();\n      if (configTimezone.name !== machineTimezone) {\n        log.warn(\n          `The timezone \"${config.timezone}\" setting is different from your machine timezone \"${machineTimezone}\". Make sure this is intended.`\n        );\n      }","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hexojs/hexo/blob/059cb17494d0632a053c24077f5bcb6ae92acc51/lib/hexo/validate_config.ts#L8-L44","documentation":"Thrown by validate_config (lib/hexo/validate_config.ts:26). config.root is a string but trims to zero length (empty or only whitespace). root is used to build every asset URL, so an empty value is rejected.","triggerScenarios":"root: '' (empty quoted string), root: '   ' (whitespace only), or root: ~ rendered as empty. A single '/' is fine because it is non-empty after trim.","commonSituations":"Setting root to an empty string by mistake; YAML quoting an empty value; a config merge/override clearing root; copy-paste error leaving root blank.","solutions":["Set root: / for a site served at the domain root.","For a sub-path install, set root: /blog/ (trailing slash).","Remove any whitespace-only value."],"exampleFix":"# before\nroot: ''\n\n# after\nroot: /","handlingStrategy":"validation","validationCode":"if (typeof hexo.config.root !== 'string' || hexo.config.root.trim().length === 0) {\n  throw new Error(\"_config.yml 'root' must not be empty\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use root: / for root-served sites, root: /blog/ for sub-paths.","Never set root to an empty or whitespace string.","Add a config sanity check to deploy scripts."],"tags":["config","validation","startup","root"],"backgroundTag":null,"analyzedSha":"059cb17494d0632a053c24077f5bcb6ae92acc51","analyzedAt":"2026-08-12T20:52:05.731Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}