Search code examples
jsonharp

_data.json variables not being loaded


I've set up Harp, and it is running and serving content, but any values stored in _data.json seem to have no effect.

Directory structure:

/
|-- _harp.json
|-- _data.json
|-- _layout.ejs
|-- index.md
|-- getting-started.md

The file _harp.json contains:

{
        "globals": {
                "title": "Home"
        }
}

_data.json contains:

{
        "getting-started": {
                "title": "Getting Started"
        }
}

And _layout.ejs contains:

<!DOCTYPE html>
<html>
        <head>
                <title><%= title %> &mdash; My Website</title>
        </head>
        <body>
               <%- yield %>
        </body>
</html>

The layout, and page contents, load correctly, and <%= title %> is replaced with the value given in _harp.json. However, when an entry exists within _data.json, no replacement is made and it continues to be replaced with the value in _harp.json.

Have I missed the obvious with this? Thank you in advance.


Solution

  • It appears that Harp required a restart, although this wasn't mentioned in Harp's documentation. It also appears to require a restart each time _data.json is modified.