Accessing Template Variables in _index.md for Homepage


#1

I just arrived at Hugo a few hours back so pardon me if the questions is too silly

Is it possible to access variables inside _index.md like so {{ .Data.Pages }}?

Here’s the directory structure & I’m trying to do this within the homepage content/_index.html

content
  _index.md
layouts
  index.html

index.html in the layouts directory has {{.Content}} in it.

I thought I could access variables in the _index.md so I’m trying to create the content for homepage in _index.md & use the layout from index.html

Any help on this is appreciated. Thanks


#2

You need to use a shortcode.


#3

You mean create a custom shortcode (that does the required work with variables) & call it in _index.md ?