hugo: Configurable ignore list (filename regular expressions) #1189

Closed
ehammond opened this Issue Jun 3, 2015 · 4 comments

Comments

Projects
None yet
4 participants
@ehammond

ehammond commented Jun 3, 2015

Per http://discuss.gohugo.io/t/hugo-server-watch-should-ignore-emacs-lock-files/1265

Please add the ability to configure a list of regular expressions that specify filename patterns that hugo server --watch should ignore as triggers for rebuilding the site.

For example, I would like to add ^\.# (Emacs lock file symlink prefix) to the list to prevent hugo rebuild and browser reload every time I start editing a file.

@bep bep added the Enhancement label Jun 3, 2015

@bep bep closed this in bed2278 Jun 3, 2015

bep added a commit that referenced this issue Jun 3, 2015

Rename WatchIgnoreFiles to IgnoreFiles
Because this isn't just about server and watching.

See #1189

bep added a commit that referenced this issue Jun 3, 2015

@ehammond

This comment has been minimized.

Show comment
Hide comment
@ehammond

ehammond Jun 3, 2015

Your speed scares me. But thank you.

ehammond commented Jun 3, 2015

Your speed scares me. But thank you.

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 3, 2015

Member

Note my latest commit - I renamed it to ignoreFiles.

Member

bep commented Jun 3, 2015

Note my latest commit - I renamed it to ignoreFiles.

bep added a commit that referenced this issue Jun 3, 2015

Add some tests for IgnoreFiles
And log error on invalid regexp.

See #1189

@mbland mbland referenced this issue in 18F/hub Jun 25, 2015

Open

Investigate switching to Hugo #326

2 of 9 tasks complete
@jethrokuan

This comment has been minimized.

Show comment
Hide comment
@jethrokuan

jethrokuan Mar 24, 2016

I'm not sure what I'm doing wrong here, but I still face the same issue on 0.16-DEV.

I have ignoreFiles = ["^\\.#"] in my config.toml, and not only does livereload not work, refreshing the page does not reflect the changes in the markdown, because the site was not rebuilt.

The output of hugo serve:

❯ hugo serve                                                                                                    09:49:23 PM 
Started building site
0 of 1 draft rendered
0 future content
8 pages created
0 non-page files copied
0 paginator pages created
0 tags created
7 categories created
in 20 ms
Watching for changes in /home/jethro/Code/blog/{content,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Change detected, rebuilding site
2016-03-24 21:51 +0800
Source changed /home/jethro/Code/blog/content/posts/.#building-aagenda.md
^C⏎      

Edit:

From what I see here, it the lock file should be ignored by default.
https://github.com/spf13/hugo/blob/b319c1896907332c542b6cebda596ed63aeca9af/source/filesystem.go#L146-L149

I'm not sure what I'm doing wrong here, but I still face the same issue on 0.16-DEV.

I have ignoreFiles = ["^\\.#"] in my config.toml, and not only does livereload not work, refreshing the page does not reflect the changes in the markdown, because the site was not rebuilt.

The output of hugo serve:

❯ hugo serve                                                                                                    09:49:23 PM 
Started building site
0 of 1 draft rendered
0 future content
8 pages created
0 non-page files copied
0 paginator pages created
0 tags created
7 categories created
in 20 ms
Watching for changes in /home/jethro/Code/blog/{content,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Change detected, rebuilding site
2016-03-24 21:51 +0800
Source changed /home/jethro/Code/blog/content/posts/.#building-aagenda.md
^C⏎      

Edit:

From what I see here, it the lock file should be ignored by default.
https://github.com/spf13/hugo/blob/b319c1896907332c542b6cebda596ed63aeca9af/source/filesystem.go#L146-L149

@andrewalexander

This comment has been minimized.

Show comment
Hide comment
@andrewalexander

andrewalexander May 29, 2016

I have the exact same problem as @jethrokuan. Just did a go get -u -v github.com/spf13/hugo, and I see the relevant lines in fileserver.go have been updated. I also added this to my config.toml: watchIgnoreFiles = ["\\.#(\\w+)\\.(\\w+)"] thinking that I could make it happen with my own regex. And yet, I experience the same no-reload and a notification that the content is changed, but it never actually rebuilds anything since the content wasn't actually updated yet. My hugo server --watch output is a bit different though:

hugo server --watch
Started building site
0 draft content
0 future content
1 pages created
0 non-page files copied
0 paginator pages created
2 tags created
2 categories created
in 24 ms
Watching for changes in /home/andrew/Projects/fancy_new_project/{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Change detected, rebuilding site
2016-05-29 15:13 -0400

It doesn't say which file changed, only that a change was detected. Not a true deal-breaker, but when I edit in Sublime, it's really nice to have that live-reload vs. having to kill the hugo process and restart every time while I edit in emacs.

I have the exact same problem as @jethrokuan. Just did a go get -u -v github.com/spf13/hugo, and I see the relevant lines in fileserver.go have been updated. I also added this to my config.toml: watchIgnoreFiles = ["\\.#(\\w+)\\.(\\w+)"] thinking that I could make it happen with my own regex. And yet, I experience the same no-reload and a notification that the content is changed, but it never actually rebuilds anything since the content wasn't actually updated yet. My hugo server --watch output is a bit different though:

hugo server --watch
Started building site
0 draft content
0 future content
1 pages created
0 non-page files copied
0 paginator pages created
2 tags created
2 categories created
in 24 ms
Watching for changes in /home/andrew/Projects/fancy_new_project/{data,content,layouts,static,themes}
Serving pages from memory
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

Change detected, rebuilding site
2016-05-29 15:13 -0400

It doesn't say which file changed, only that a change was detected. Not a true deal-breaker, but when I edit in Sublime, it's really nice to have that live-reload vs. having to kill the hugo process and restart every time while I edit in emacs.

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

Add configurable list to ignore files in server watch
The following inside `config.toml` will ignore files ending with `.foo` and `.boo`.

```
watchIgnoreFiles = [ "\\.foo$", "\\.boo$" ]
```

The above is is a list of Reqular Expressions, but note the escaping of the `\` to make TOML happy.

Fixes #1189

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

Rename WatchIgnoreFiles to IgnoreFiles
Because this isn't just about server and watching.

See #1189

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

tychoish added a commit to tychoish/hugo that referenced this issue Aug 13, 2017

Add some tests for IgnoreFiles
And log error on invalid regexp.

See #1189
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment