question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't access site.data variable

See original GitHub issue

Hello I have menu.json file in _data folder:

[
  {"url":"","index":"0"},
  {"url":"about","index":"1"},
  {"url":"portfolio","index":"2"},
  {"url":"expertise","index":"3"},
  {"url":"contact","index":"4"}
]

I’m trying to log site.data.menu from main.js:

console.log(site.data.menu)

And have this error: console error

Can someone help me with this please ?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
eko24commented, Jul 2, 2016

If you want use files from _data folder in your .js files, you can achieve it with:

var _menu = require('../_data/menu.json');

Works like a charm !

0reactions
eko24commented, Jan 12, 2017

You’re welcome @driera

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't access Site variables inside nested partial - HUGO
Hi ! I got an issue recently and I can't resolve it on my own. It might be really simple to solve it...
Read more >
vue.js - Can't access data variable inside watcher, inside .map()
I have defined types and history variables inside data and in watch, I am trying to access another variable rather than the one...
Read more >
ReferenceError: can't access lexical declaration 'X' before ...
A lexical variable was accessed before it was initialized. This happens within any block statement, when variables declared with let or const ...
Read more >
Can't access `ELEVENTY_ENV` data · Issue #1886 - GitHub
I'm trying to set the ELEVENTY_ENV in my site data file, following the Exposing environment variables it's not returning anything.
Read more >
Frequently Asked Questions (FAQ) - IPUMS International
Why can't I open the data file? ... These links open the variables page: the primary tool for exploring the contents of IPUMS-International....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found