# $.Site.Pages is nil inside a data partial

**URL:** <https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128>\
**Category:** support\
**Created:** [October 30, 2020, 4:13pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128 "2020-10-30T16:13:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nader\_K\_Rad](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nader_k_rad/32/7676_2.png) [@Nader\_K\_Rad](https://discourse.gohugo.io/u/Nader_K_Rad)\
**Post date:** [October 30, 2020, 4:13pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128/1 "2020-10-30T16:13:40Z")

</div>

I have a partial that is called like this:

```auto
{{ partial "a.html" $.Site.Data.something.somethingelse }}

```

Inside that partial, `$.Site.Pages` is nil (so is `.Site.Pages`). Isn’t it possible to have access to all pages in a context like this?

---

<div class="post-metadata">

**Author:** ![alexandros](https://avatars.discourse-cdn.com/v4/letter/a/ecc23a/32.png) [@alexandros](https://discourse.gohugo.io/u/alexandros)\
**Post date:** [October 30, 2020, 4:52pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128/2 "2020-10-30T16:52:18Z")

</div>

As per the [documentation](https://gohugo.io/templates/partials/#readout)

> All partials are called within your templates using the following pattern:
> 
> `{{ partial "<PATH>/<PARTIAL>.html" . }}`  
> …  
> In the pattern above, note how “the dot” ( `.` ) is required as the second argument to give the partial context.

More on the dot: [over here](https://gohugo.io/templates/introduction/#the-dot)

I don’t quite understand what you are trying to achieve, since that is not the syntax typically used to call a set of data files. BTW `.Site.Data ` is used in templates to call files that reside under a project’s `/data/` folder: see [Data Templates](https://gohugo.io/templates/data-templates/)

I do not see `$.Site.Pages` in `{{ partial "a.html" $.Site.Data.something.somethingelse }}`

You need to share your project’s source code and offer a description about what you are trying to render through said partial.

---

<div class="post-metadata">

**Author:** ![Nader\_K\_Rad](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nader_k_rad/32/7676_2.png) [@Nader\_K\_Rad](https://discourse.gohugo.io/u/Nader_K_Rad)\
**Post date:** [October 30, 2020, 5:18pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128/3 "2020-10-30T17:18:40Z")

</div>

For example, I have a data file like this:

```auto
data/category-a/sub-category-3/item42.yaml

```

I run the following to create a block of content based on that:

```auto
{{ partial "show-item.html" $.Site.Data.category-a.sub-category-3.item42 }}

```

This has been working fine for me. However, now I need to add something extra to this block of content, and its information comes from a page (with a certain relationship to the data file) rather than the data file itself, but it seems like I can’t access pages with .Site.Pages or .GetPage (or .GetPage) inside this partial.

For what you mentioned about the dot, I’d have to use a dict to pass both the dot and the data file to the partial, which makes my templates a little messy and I prefer to avoid it if I can. I was hoping that the existing input could give the partial enough context to access “$”, or that there’s another simple way of doing it.

---

<div class="post-metadata">

**Author:** ![pamubay](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pamubay/32/17838_2.png) [@pamubay](https://discourse.gohugo.io/u/pamubay)\
**Post date:** [October 30, 2020, 10:07pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128/4 "2020-10-30T22:07:31Z")

</div>

you could try `site` global function, it’s _undocumented feature._

access via `.Site` variable

```auto
{{ .Site.GetPage ... }}}

```

access via `site` function

```auto
{{ site.GetPage ... }}}

```

> <https://github.com/gohugoio/hugoDocs/issues/1119>
>
> gohugoio/hugo#5470 is great, but AFAICT it's not documented anywhere. I was writing a partial and thinking "I thought there was some...

---

<div class="post-metadata">

**Author:** ![divinerites](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/divinerites/32/12625_2.png) [@divinerites](https://discourse.gohugo.io/u/divinerites)\
**Post date:** [October 30, 2020, 10:55pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128/5 "2020-10-30T22:55:40Z")

</div>

> [@pamubay](#):
>
> it’s _undocumented feature._

> **[Site variables](https://gohugo.io/variables/site/#get-the-site-object-from-a-partial)**
>
> Use these methods with Site objects. A multilingual project will have two or more sites, one for each language.

---

<div class="post-metadata">

**Author:** ![Nader\_K\_Rad](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/nader_k_rad/32/7676_2.png) [@Nader\_K\_Rad](https://discourse.gohugo.io/u/Nader_K_Rad)\
**Post date:** [October 31, 2020, 12:02pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128/6 "2020-10-31T12:02:19Z")

</div>

Thanks! That solved the problem.

---

<div class="post-metadata">

**Author:** ![system](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/system/32/1_2.png) [@system](https://discourse.gohugo.io/u/system)\
**Post date:** [November 2, 2020, 12:02pm UTC](https://discourse.gohugo.io/t/site-pages-is-nil-inside-a-data-partial/29128/7 "2020-11-02T12:02:27Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
