# ignoreFiles not ignoring files

**URL:** <https://discourse.gohugo.io/t/ignorefiles-not-ignoring-files/41886>\
**Category:** support\
**Created:** [December 13, 2022, 1:55pm UTC](https://discourse.gohugo.io/t/ignorefiles-not-ignoring-files/41886 "2022-12-13T13:55:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anmith](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anmith](https://discourse.gohugo.io/u/anmith)\
**Post date:** [December 13, 2022, 1:55pm UTC](https://discourse.gohugo.io/t/ignorefiles-not-ignoring-files/41886/1 "2022-12-13T13:55:40Z")

</div>

Hi,  
I have the following structure

```auto
content
    /post
        /my-article
            index.html
            /comments
                a.json
                b.json

```

The contents of the datafiles is processed by “index.html” (os.readDir & GetJSON) and the “\*.json” files should not be available in the “public” directory.

As far as I understood the [documentation](https://gohugo.io/getting-started/configuration/#ignore-content-and-data-files-when-rendering), adding “ignoreFiles” to my “config.toml” should do the trick.

However, when adding

```auto
ignoreFiles = ['\.json$']

```

the json-files are still copied over, but when using

```auto
ignoreFiles = ['comments/*']

```

in ignoreFiles the files (and folder) are not copied.

However, this doesn’t look like a valid “regular expression to match against the absolute file path” and so I’m trying to find out what I’m doing wrong …

Any advices?

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [December 13, 2022, 4:04pm UTC](https://discourse.gohugo.io/t/ignorefiles-not-ignoring-files/41886/2 "2022-12-13T16:04:57Z")

</div>

> [@anmith](#):
>
> Any advices?

`ignoreFiles` has some limitations. I have not read your case, but I would recommend that you instead look at

> **[Configure Hugo modules](https://gohugo.io/hugo-modules/configuration/#module-config-mounts)**
>
> This page describes the configuration options for a module.

And the options for include\*/excludeFiles.

I will add a linke to the documentation to make this easier to discover.

---

<div class="post-metadata">

**Author:** ![anmith](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@anmith](https://discourse.gohugo.io/u/anmith)\
**Post date:** [December 13, 2022, 4:12pm UTC](https://discourse.gohugo.io/t/ignorefiles-not-ignoring-files/41886/3 "2022-12-13T16:12:40Z")

</div>

Thanks, I’ll look into it.
