{"record":{"id":"847cde92d88f449f","repo":"gohugoio/hugo","slug":"failed-to-process-q-w","errorCode":null,"errorMessage":"failed to process %q: %w","messagePattern":"failed to process %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"publisher/publisher.go","lineNumber":108,"sourceCode":"}\n\n// Publish applies any relevant transformations and writes the file\n// to its destination, e.g. /public.\nfunc (p DestinationPublisher) Publish(d Descriptor) error {\n\tif d.TargetPath == \"\" {\n\t\treturn errors.New(\"Publish: must provide a TargetPath\")\n\t}\n\n\tsrc := d.Src\n\n\ttransformers := p.createTransformerChain(d)\n\n\tif len(transformers) != 0 {\n\t\tb := bp.GetBuffer()\n\t\tdefer bp.PutBuffer(b)\n\n\t\tif err := transformers.Apply(b, d.Src); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to process %q: %w\", d.TargetPath, err)\n\t\t}\n\n\t\t// This is now what we write to disk.\n\t\tsrc = b\n\t}\n\n\tf, err := helpers.OpenFileForWriting(p.fs, d.TargetPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer f.Close()\n\n\tvar w io.Writer = f\n\n\tif p.htmlElementsCollector != nil && d.OutputFormat.IsHTML {\n\t\tw = io.MultiWriter(w, newHTMLElementsCollectorWriter(p.htmlElementsCollector))\n\t}\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/publisher/publisher.go#L90-L126","documentation":"Returned by DestinationPublisher.Publish when the transformer chain (URL rewriting, livereload injection, generator tag injection, or minification) fails to apply to the source content. It wraps the transformer error and names the TargetPath so the failing output file is identifiable. This is the final transformation step before the file is written to the publish filesystem.","triggerScenarios":"Publishing a Descriptor whose Src contains malformed HTML/XML that breaks the minifier or URL replacer, enabling minify with an output format lacking a registered minifier config, or injecting livereload/generator transforms on content the transformer cannot parse.","commonSituations":"Enabling minify = true in config for an output format with no matching minifier, a template producing invalid HTML that the minifier rejects, or a URL replacement transform failing on non-absolute-able URLs.","solutions":["Disable minify for the affected output format and re-run to isolate whether the minifier is the cause.","Inspect the wrapped error to identify which transformer (absURL, livereload, generator, minify) failed.","Fix the template producing malformed HTML/XML so the transformer can parse it.","Verify the output format and media type have a registered minifier if minify is enabled."],"exampleFix":"// before: minify enabled, malformed HTML in template breaks publish\nminify: true\n\n// after: fix the template output, or scope minify\n[minify]\nminifyOutput = true\ndisableXML = true  # if XML minifier is the culprit","handlingStrategy":"validation","validationCode":"// Validate content is well-formed before publishing; disable minify to isolate.\nfunc safePublish(p publisher.Publisher, d publisher.Descriptor, minify bool) error {\n    d.Minify = minify\n    if minify {\n        peek, err := io.ReadAll(d.Src)\n        if err != nil { return err }\n        d.Src = bytes.NewReader(peek)\n        // optionally validate HTML parseability here\n    }\n    return p.Publish(d)\n}","typeGuard":null,"tryCatchPattern":"if err := p.Publish(d); err != nil {\n    // err already names the TargetPath; inspect wrapped cause\n    return err\n}","preventionTips":["Test minify on a small output format before enabling globally.","Keep templates producing valid HTML/XML so transformers never choke.","Register a minifier for every output format you enable minify on."],"tags":["publisher","minify","transform","publish","html"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}