# Is it possible to access page variables from outside?

**URL:** <https://talk.jekyllrb.com/t/is-it-possible-to-access-page-variables-from-outside/9335>\
**Category:** Help\
**Created:** [July 23, 2024, 6:50am UTC](https://talk.jekyllrb.com/t/is-it-possible-to-access-page-variables-from-outside/9335 "2024-07-23T06:50:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![elyahw](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@elyahw](https://talk.jekyllrb.com/u/elyahw)\
**Post date:** [July 23, 2024, 6:50am UTC](https://talk.jekyllrb.com/t/is-it-possible-to-access-page-variables-from-outside/9335/1 "2024-07-23T06:50:25Z")

</div>

I have a page, say `{{ site.url }}/books.html`.

I have a variable defined in that page `{% assign main_1 = "History" %}` I am using this variable inside an `id` property like so: `<a id="{{ main_1 }}" href="#{{ main_1 }}"> H1_HEADING </a>` to create inner page links.

I would like to gather all of these variables and put them in the **sidepanel** , to create a list of inner page links. An example is this page: [Modeling Non-linear Least Squares — Ceres Solver](http://ceres-solver.org/nnls_modeling.html#sizedcostfunction) (notice how the links in the sidepanel are internal links on the same page)

My question is: Is it possible to access the variable `{{ main_1 }}` from outside of the current page, for example from inside `includes/sidepanel.html`?

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [July 23, 2024, 3:02pm UTC](https://talk.jekyllrb.com/t/is-it-possible-to-access-page-variables-from-outside/9335/2 "2024-07-23T15:02:22Z")

</div>

you can pass parameters into an include if that would work. But you would need to call the include from that page.

You can access site variables or data files from anywhere. A data file could work depending on how complex it is but might be harder to maintain.

---

<div class="post-metadata">

**Author:** ![elyahw](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@elyahw](https://talk.jekyllrb.com/u/elyahw)\
**Post date:** [July 23, 2024, 3:30pm UTC](https://talk.jekyllrb.com/t/is-it-possible-to-access-page-variables-from-outside/9335/3 "2024-07-23T15:30:06Z")

</div>

Thank you. How can I pass the parameters into an include? And which parameters please?

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [July 23, 2024, 6:40pm UTC](https://talk.jekyllrb.com/t/is-it-possible-to-access-page-variables-from-outside/9335/4 "2024-07-23T18:40:19Z")

</div>

you should be able to pass in the variable to the include and then use it in the include.

see the docs:

> **[Includes](https://jekyllrb.com/docs/includes/#passing-parameters-to-includes)**
>
> The include tag allows you to include the content from another file stored in the \_includes folder:

---

<div class="post-metadata">

**Author:** ![elyahw](https://avatars.discourse-cdn.com/v4/letter/e/bbe5ce/32.png) [@elyahw](https://talk.jekyllrb.com/u/elyahw)\
**Post date:** [July 24, 2024, 10:51am UTC](https://talk.jekyllrb.com/t/is-it-possible-to-access-page-variables-from-outside/9335/5 "2024-07-24T10:51:04Z")

</div>

Thanks very much. This worked exactly as I wanted.
