Skip to content

netlify dev + custom 404 page = unicode rendering problems #1945

@jbrains

Description

@jbrains

Describe the bug

I’m creating a custom 404 page for my Jekyll site that uses some HTML5 entities (“smart” single quote, non-breaking space). There appears to be a Unicode problem when I preview the site using netlify dev compared to when I use Jekyll’s own web server (webrick, I guess).

When serving the site with webrick/jekyll serve, the text looks normal. When serving the site with netlify dev, there is the usual Unicode problem where the smart single quote is rendered as ’.

All my other pages are rendered correctly when serving the site with netlify dev. So far I’ve only seen this problem on the custom 404 page. All the pages have the same <meta charset> tag set to UTF-8.

I do not notice any difference between the generated 404.html file and (for example) the generated index.html that might cause them to be rendered differently, so I conclude that this points to a defect somewhere.

To Reproduce

I have not tried to produce a minimal failing example, so I don't know which of these steps are irrelevant.

Steps to reproduce the behavior:

  1. Create a Jekyll project.
  2. Create a custom 404 Markdown document ($SOURCE_ROOT/404.md) and add text that uses an apostrophe, such as "can't".
  3. Create a welcome Markdown document ($SOURCE_ROOT/index.md) and add text that uses an apostrophe.
  4. Add a rule to _redirects that ensures that the custom 404 page will handle HTTP status 404 responses.
  5. netlify build. Notice that the HTML pages look correct in a text editor.
  6. netlify dev, visit both pages, and notice that the 404 page renders incorrectly ("can’t"), although the welcome page renders correctly.
  7. jekyll serve, visit both pages, and notice that the 404 page renders correctly.

Configuration

  • If possible, please copy/paste below your netlify.toml.
[build]
  command = "jekyll build"
  publish = "openshift-www.jbrains.ca/www"
  • Please enter the following command in a terminal and copy/paste its output:
npx envinfo --system --binaries --npmPackages netlify-cli --npmGlobalPackages netlify-cli
  System:
    OS: Linux 5.8 Pop!_OS 20.10
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 10.83 GB / 31.24 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 15.7.0 - ~/.n/bin/node
    Yarn: 1.22.10 - ~/.npm-packages/bin/yarn
    npm: 7.4.3 - ~/.n/bin/npm
    Watchman: 4.9.0 - /usr/bin/watchman
  npmGlobalPackages:
    netlify-cli: 3.10.2

Expected behavior

Both the welcome page and the 404 page should be rendered with the correct Unicode character set.

CLI Output

The CLI output looks normal.

◈ Netlify Dev ◈
◈ Ignored general context env var: LANG (defined in process)
◈ Ignored general context env var: LANGUAGE (defined in process)
◈ Starting Netlify Dev with jekyll
Configuration file: /home/jbrains/Workspaces/www.jbrains.ca/_config.yml
            Source: /home/jbrains/Workspaces/www.jbrains.ca/source
       Destination: /home/jbrains/Workspaces/www.jbrains.ca/openshift-www.jbrains.ca/www
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 1.291 seconds.
 Auto-regeneration: enabled for 'source/'
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.

   ┌─────────────────────────────────────────────────┐
   │                                                 │
   │   ◈ Server now ready on http://localhost:8888   │
   │                                                 │
   └─────────────────────────────────────────────────┘

Additional context

I have not noticed this problem before, so I can't provide any clues as to whatever this behavior has been recently introduced by a change. Sorry!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions