# Using post\_formatter with an IMPORTED macro

**URL:** <https://community.hubspot.com/t/using-post-formatter-with-an-imported-macro/20351>\
**Category:** CMS Development\
**Created:** [April 24, 2020, 4:13pm UTC](https://community.hubspot.com/t/using-post-formatter-with-an-imported-macro/20351 "2020-04-24T16:13:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mIIwaukee](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miiwaukee/32/50443_2.png) [@mIIwaukee](https://community.hubspot.com/u/mIIwaukee)\
**Post date:** [April 24, 2020, 4:13pm UTC](https://community.hubspot.com/t/using-post-formatter-with-an-imported-macro/20351/1 "2020-04-24T16:13:25Z")

</div>

Hi,

Running into issues with macros and related posts (related\_blog\_posts).

**Macros are an external file that’s imported like this:**

{% import ‘/\_blog-macros.html’ as blog\_macros %}

**A macro I want to use is**

{% macro format\_post(blog\_post) %} {% endmacro %}

**Works everywhere:**

{{ blog\_macros.format\_post(the\_post) }}

**Exception: related blog posts wont accept the imported syntax…**

{% related\_blog\_posts limit=3, post\_formatter=‘blog\_macros.format\_post’ %}

**Errors as**

“Macro function does not exist”

Am I missing something?

thanks!

mark

---

<div class="post-metadata">

**Author:** ![sharonlicari](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sharonlicari/32/101479_2.png) [@sharonlicari](https://community.hubspot.com/u/sharonlicari)\
**Post date:** [April 28, 2020, 11:16am UTC](https://community.hubspot.com/t/using-post-formatter-with-an-imported-macro/20351/2 "2020-04-28T11:16:49Z")

</div>

Hey @mIIwaukee

Thanks for reaching out! I want to tag in some subject matter experts to get their insight on this situation.

Hey, @JanetArmstrong @ajchapman20 @narmstrong do you have any suggestions for @mIIwaukee ?

Thanks,

Sharon

---

<div class="post-metadata">

**Author:** ![BenSBM](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bensbm/32/75413_2.png) [@BenSBM](https://community.hubspot.com/u/BenSBM)\
**Post date:** [April 28, 2020, 5:58pm UTC](https://community.hubspot.com/t/using-post-formatter-with-an-imported-macro/20351/3 "2020-04-28T17:58:36Z")

</div>

Hi @mIIwaukee

This looks to me like a possible oversight from HubSpot where it won’t let you use an imported macro. A workaround does exist, however being a workaround it’s not 100% ideal.

The idea is to add a macro that acts as a wrapper, and passes the post info to the import macro. It doesn’t really help as far as keeping all macros contained within one file, but does help in the sense that it at least keeps the main post formatter macro in a separate file.

```auto
{% import '/path/to/macros.html' as macros %}
{% macro inline_formatter(post) %}
 {{ macros.custom_post_formatter(post) }}
{% endmacro %}

{% related_blog_posts limit=3, post_formatter="inline_formatter" %}

```

---

<div class="post-metadata">

**Author:** ![mIIwaukee](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miiwaukee/32/50443_2.png) [@mIIwaukee](https://community.hubspot.com/u/mIIwaukee)\
**Post date:** [April 28, 2020, 6:46pm UTC](https://community.hubspot.com/t/using-post-formatter-with-an-imported-macro/20351/4 "2020-04-28T18:46:10Z")

</div>

Thanks @BenSBM for sharing your insightful comment!
