static: Preserve .gitignore and .gitattributes in --cleanDestinationDir

Fixes #14097
This commit is contained in:
Ahamed_Meyan
2025-11-16 15:40:20 +05:30
committed by GitHub
parent 94a6233aab
commit 5e6b269c41
+9 -1
View File
@@ -464,7 +464,15 @@ func (c *hugoBuilder) copyStaticTo(sourceFs *filesystems.SourceFilesystem) (uint
infol.Logf("removing all files from destination that don't exist in static dirs")
syncer.DeleteFilter = func(f fsync.FileInfo) bool {
return f.IsDir() && strings.HasPrefix(f.Name(), ".")
name := f.Name()
// Keep .gitignore and .gitattributes anywhere
if name == ".gitignore" || name == ".gitattributes" {
return true
}
// Keep Hugo's original dot-directory behavior
return f.IsDir() && strings.HasPrefix(name, ".")
}
}
start := time.Now()