jekyll-postfiles: Invalide byte sequence in UTF-8

Hi, I have an error even before building, just executing jekyll doctor.

Error: could not read file /Users/boris/Projects/perso/blog/jekyll-private/_posts/fr/papa/2016/2016-07-09-et-le-feu-ca-brule/1.jpg: invalid byte sequence in UTF-8

The same error is produced when I try to serve in verbose mode, I got this:

       ...
       EntryFilter: excluded /scripts
       EntryFilter: excluded /tasks
       EntryFilter: excluded /vendor
           Reading: _posts/en/default/2005-01-01-typo-test/2005-01-01-typo-test.md
           Reading: _posts/en/default/2014/2014-03-13-conquering-ab-testing/2014-03-13-conquering-ab-testing.md
           ... 
           ...
           Reading: _posts/fr/papa/2016/2016-07-01-esperanto/2016-07-01-esperanto.md
           Reading: _posts/fr/papa/2016/2016-07-09-et-le-feu-ca-brule/1.jpg
             Error: could not read file /Users/boris/Projects/perso/blog/jekyll-private/_posts/fr/papa/2016/2016-07-09-et-le-feu-ca-brule/1.jpg: invalid byte sequence in UTF-8
           Reading: _posts/fr/papa/2016/2016-07-09-et-le-feu-ca-brule/2016-07-09-et-le-feu-ca-brule.md
           Reading: _posts/fr/papa/2016/2016-07-10-tonton-et-tatie/2016-07-10-tonton-et-tatie.md
           ...
           ...
          Reading: _confs/sensibilisation-web.md
           Reading: _confs/web-disruption-continue.md
         Rendering: 2016/index.html
  Pre-Render Hooks: 2016/index.html
  Rendering Liquid: 2016/index.html
  Rendering Markup: 2016/index.html
  Rendering Layout: 2016/index.html
         Rendering: _posts/fr/default/2016/2016-06-15-conseils-pour-les-etudiants/2016-06-15-conseils-pour-les-etudiants.md
  Pre-Render Hooks: _posts/fr/default/2016/2016-06-15-conseils-pour-les-etudiants/2016-06-15-conseils-pour-les-etudiants.md
  Rendering Liquid: _posts/fr/default/2016/2016-06-15-conseils-pour-les-etudiants/2016-06-15-conseils-pour-les-etudiants.md
  Rendering Markup: _posts/fr/default/2016/2016-06-15-conseils-pour-les-etudiants/2016-06-15-conseils-pour-les-etudiants.md
         Requiring: kramdown
         Rendering: _posts/fr/papa/2016/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans.md
  Pre-Render Hooks: _posts/fr/papa/2016/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans.md
  Rendering Liquid: _posts/fr/papa/2016/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans.md
  Rendering Markup: _posts/fr/papa/2016/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans/2016-06-26-la-blockchain-expliquee-a-un-enfant-de-cinq-ans.md
  Liquid Exception: undefined method `gsub' for nil:NilClass in _layouts/archives-year.html
jekyll 3.2.0 | Error:  undefined method `gsub' for nil:NilClass

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 36 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Ok, thanks @w1ne ! 🙏

@nhoizey I’m not able to reproduce the issue, so it seems to be fixed.

Hi. I am having the exact same issue. Jekyll version 3.7.3. My posts directory looks like

_posts/
    2018-05-01-first-post.md
    2018-05-02-post-in-directory/
        2018-05-02-post-in-directory.md
        one.jpg
        two.jpg
    2018-05-03-another-post.md

Running bundle exec jekyll build gives the error

Error: could not read file .../_posts/2018-05-02-post-in-directory/one.jpg: invalid byte sequence in UTF-8
Error: could not read file .../_posts/2018-05-02-post-in-directory/two.jpg: invalid byte sequence in UTF-8

However, when I rename the directory containing the image files, I no longer get an error. I.e. with the following directory structure, everything is fine.

_posts/
    2018-05-01-first-post.md
    post-in-directory/
        2018-05-02-post-in-directory.md
        one.jpg
        two.jpg
    2018-05-03-another-post.md

Just understood why I had this error with these two files: it’s because the file names were starting with dates. 2004-09-26-Catching-the-sun.jpg for example.

I suppose Jekyll was messing with these files, thinking they were posts.

So… I don’t have the issue anymore after renaming the image files.

@borisschapira @RRMoelker @DirtyF do you still have the issue?