# Include \`macro\` in content

**URL:** <https://zola.discourse.group/t/include-macro-in-content/1693>\
**Category:** Support\
**Created:** [March 26, 2023, 10:33pm UTC](https://zola.discourse.group/t/include-macro-in-content/1693 "2023-03-26T22:33:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemeroc](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/hemeroc/32/965_2.png) [@hemeroc](https://zola.discourse.group/u/hemeroc)\
**Post date:** [March 26, 2023, 10:33pm UTC](https://zola.discourse.group/t/include-macro-in-content/1693/1 "2023-03-26T22:33:58Z")

</div>

Hi,

I have a content page where I currently call a `shortcode` that renders some data.  
Now I want to generate links to other pages based on the path for this I would need to use the `get_page` function which is not available in `shortcodes` the documentation says that the alternative is a `macro` but I don’t know how to load a macro from my markdown file in content.

Can someone help me or point me into another direction.  
What I want to achieve is to link to another page. I have the `relative_path` to the page and need to generate a link with the `page.title`.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![mrblubb](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mrblubb](https://zola.discourse.group/u/mrblubb)\
**Post date:** [May 12, 2023, 5:25pm UTC](https://zola.discourse.group/t/include-macro-in-content/1693/2 "2023-05-12T17:25:56Z")

</div>

Just bumping this question. I stumble about the same problem.

I want to include a project list from a directory in between content pieces:

```auto
# some markdown
{{ projectlist() }}
# some more markdown

```

Shortcodes don’t work and I can’t figure out how to include macros in the markdown file.

Any help would be appreciated!

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [May 13, 2023, 1:12am UTC](https://zola.discourse.group/t/include-macro-in-content/1693/3 "2023-05-13T01:12:27Z")

</div>

You can’t include macros in the markdown files. What do you mean shortcodes don’t work?

---

<div class="post-metadata">

**Author:** ![mrblubb](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mrblubb](https://zola.discourse.group/u/mrblubb)\
**Post date:** [May 13, 2023, 6:17am UTC](https://zola.discourse.group/t/include-macro-in-content/1693/4 "2023-05-13T06:17:29Z")

</div>

Shortcodes technically work for me, but for this use-case I cannot use them as they would need to support `get_section`:  
I try to iterate over all projects in a folder (content / projects / project 1…5 / index.md) and retrieve the project’s title/date/etc. This list should then be embedded in the middle of regular content.  
Similar to:  
‘hi, here are some projects’  
{{ projectlist }} ← this is the impossible shortcode with `get_section`  
‘thanks for checking them out’

I think the confusion comes from the documentation, where macros are mentioned as alternative to shortcodes. After taking a second look, I realized that the docs also clearly say that macros are called from templates – sorry.

The original problem remains: how can one integrate _automatically retrieved_ content from pages surrounded by regular markdown content?  
Is there another way of doing this that won’t require `get_section`?

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/hugotrentesaux/32/105_2.png) [@HugoTrentesaux](https://zola.discourse.group/u/HugoTrentesaux)\
**Post date:** [June 21, 2023, 11:28am UTC](https://zola.discourse.group/t/include-macro-in-content/1693/5 "2023-06-21T11:28:48Z")

</div>

I found a workaround to use macros in markdown:

- define a string that will be replaced (example `[TOC]` or `[GALLERY]`)
- define a macro that replace the string by a macro call
- wrap your content in the replacement macro

You have examples in my seagull theme:

> **[seagull](https://git.42l.fr/HugoTrentesaux/seagull/src/branch/master/templates/macros.html#L139-L146)**
>
> An other Zola theme
