I advise you to use this Bep’s module as a basis. It works really fine.
And may be look at this thread to see if this is your case, and try the Hugo dev version who provide a fix