# Does hugo server remove stale files?

**URL:** <https://discourse.gohugo.io/t/does-hugo-server-remove-stale-files/57365>\
**Category:** support\
**Created:** [July 18, 2026, 5:59pm UTC](https://discourse.gohugo.io/t/does-hugo-server-remove-stale-files/57365 "2026-07-18T17:59:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vistad](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/vistad/32/20509_2.png) [@vistad](https://discourse.gohugo.io/u/vistad)\
**Post date:** [July 18, 2026, 5:59pm UTC](https://discourse.gohugo.io/t/does-hugo-server-remove-stale-files/57365/1 "2026-07-18T17:59:13Z")

</div>

### Does `hugo server` remove stale files from `public/` when content is deleted?

I’m seeing what appears to be stale output while using `hugo server`, and I’d like to know whether this is expected behavior or if I’m missing a configuration option.

### Environment

- Hugo server

- Linux Mint

- Start command:

```auto
HUGO_ENVIRONMENT=development hugo server --disableFastRender

```

### Test

1. Create a content directory:

```auto
content/en/house/acmecorp/

```

1. Hugo generates the website correctly.

2. Delete the entire directory:

```auto
content/en/house/acmecorp/

```

1. Verify it is really gone:

```auto
find content -name acmecorp

```

returns nothing.

1. However, the generated directory still exists:

```auto
find public -name acmecorp

```

returns:

```auto
public/house/acmecorp

```

1. Visiting

```auto
http://localhost:1313/house/acmecorp/

```

still displays the previously generated website.

If I stop the server, delete everything from `public/`, and restart `hugo server`, the URL correctly returns “Page Not Found”.

### Question

Is this the expected behavior of `hugo server`?

Should stale output under `public/` remain after the corresponding content has been deleted?

Or is there a recommended option or workflow that automatically removes obsolete generated files while the development server is running?

I’m trying to determine whether I should manually clean `public/`, or whether Hugo provides a built-in solution for this use case.

---

<div class="post-metadata">

**Author:** ![irkode](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/irkode/32/26135_2.png) [@irkode](https://discourse.gohugo.io/u/irkode)\
**Post date:** [July 18, 2026, 7:35pm UTC](https://discourse.gohugo.io/t/does-hugo-server-remove-stale-files/57365/2 "2026-07-18T19:35:18Z")

</div>

Neither `hugo` nor `hugo server` delete stale files. the purely generate files based on the sources/layouts/…

the only option is _cleanDestinationDir_ but this only affects static files.

how often to purge the public directory depends on what and how much is changed. and ofc on the build time.

a stale content file is mostly harmless. there is no path from the generated pages to it anymore.

definitely before publishing a cleanup is imho mandatory.

for small projects i just always delete public each time starting the server.

---

<div class="post-metadata">

**Author:** ![vistad](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/vistad/32/20509_2.png) [@vistad](https://discourse.gohugo.io/u/vistad)\
**Post date:** [July 19, 2026, 9:56am UTC](https://discourse.gohugo.io/t/does-hugo-server-remove-stale-files/57365/3 "2026-07-19T09:56:52Z")

</div>

Thank you irkode!

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [July 19, 2026, 5:58pm UTC](https://discourse.gohugo.io/t/does-hugo-server-remove-stale-files/57365/4 "2026-07-19T17:58:04Z")

</div>

> [@irkode](#):
>
> cleanDestinationDir

To clarify, the `--cleanDestinationDir` flag or `cleanDestinationDir` config setting operates on the `public` directory, but only if a `staticDir` exists.

> Whether to remove files from the `publishDir` that do not exist in the `staticDir` when building the site. This setting will not take effect if the `staticDir` does not exist. Note that `.gitignore` and `.gitattributes` files, along with directories named `.git`, are always preserved in the `publishDir`.

[https://gohugo.io/configuration/all/#cleandestinationdir](https://gohugo.io/configuration/all/#cleandestinationdir)

Also see [https://github.com/gohugoio/hugo/issues/8433](https://github.com/gohugoio/hugo/issues/8433).

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [July 21, 2026, 5:59pm UTC](https://discourse.gohugo.io/t/does-hugo-server-remove-stale-files/57365/5 "2026-07-21T17:59:02Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
