# how to use a variable for module parameter?

**URL:** <https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002>\
**Category:** CMS Development\
**Created:** [August 29, 2018, 1:46pm UTC](https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002 "2018-08-29T13:46:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andre9000](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/andre9000/32/53869_2.png) [@andre9000](https://community.hubspot.com/u/andre9000)\
**Post date:** [August 29, 2018, 1:46pm UTC](https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002/1 "2018-08-29T13:46:17Z")

</div>

Hi,

I am trying to link the social share module with a custom url, provided in the template:

```auto
{% widget_block social_sharing "my_social_sharing" label='Social Sharing', use_page_url=False, link=module.link.href, overrideable=True %}
 {% widget_attribute "twitter" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "twitter", "img_src": "https://static.hubspot.com/final/img/common/icons/social/twitter-24x24.png"}{% end_widget_attribute %}
 {% widget_attribute "linkedin" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "linkedin", "img_src": "https://static.hubspot.com/final/img/common/icons/social/linkedin-24x24.png"}{% end_widget_attribute %}
 {% widget_attribute "facebook" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "facebook", "img_src": "https://static.hubspot.com/final/img/common/icons/social/facebook-24x24.png"}{% end_widget_attribute %}
 {% widget_attribute "email" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "email", "img_src": "https://static.hubspot.com/final/img/common/icons/social/email-24x24.png"}{% end_widget_attribute %}
{% end_widget_block %}

```

The important part is:

`link=module.link.href`

However, this doesn’t work. When I try to share via facebook, I get:

`href should represent a valid URL`

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [August 29, 2018, 1:55pm UTC](https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002/2 "2018-08-29T13:55:21Z")

</div>

@andre9000 - what is:

`module.link.href`

is this a field you added inside the custom module you’re building?

if this is a custom field you created, is it just a text field?

---

<div class="post-metadata">

**Author:** ![Jsum](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jsum/32/20405_2.png) [@Jsum](https://community.hubspot.com/u/Jsum)\
**Post date:** [August 29, 2018, 8:09pm UTC](https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002/3 "2018-08-29T20:09:39Z")

</div>

@andre9000,

It looks like you are trying to add a parameter to the facebook url?

The fact that you are getthing the invalid url error means you are on the right track because you are messing with the url. Considering you are triny to add a query or paremeter to the url and it isn’t working, I’m getting you aren’t using ‘?’ or ‘&’. ‘?’ starts a query and ‘&’ continues it:

`www.website.com/?param1=value1&param2=value2`

If your adding onto the facebook url, chances are it already has a string of queries, you’d have to check, but if so you can just add onto it with &.

Need help? [Hire Us Here](https://www.upwork.com/o/companies/_~0124e15ff34efb3871/)

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [August 29, 2018, 8:14pm UTC](https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002/4 "2018-08-29T20:14:16Z")

</div>

@Jsum - I believe he’s getting the error because he’s probably seeing this in the compiled code:

`http://facebook.com/share?module.link.href`

that’s why I was wondering where that link field was coming from since it’s not getting the dictionary contents. It’s just getting module.link.href as plain text.

---

<div class="post-metadata">

**Author:** ![Jsum](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jsum/32/20405_2.png) [@Jsum](https://community.hubspot.com/u/Jsum)\
**Post date:** [August 30, 2018, 6:18am UTC](https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002/5 "2018-08-30T06:18:34Z")

</div>

ah I see. @andre9000 are you’re using the appropriate syntax?

`http://facebook.com/share?{{ module.link.href }}`

Need help? [Hire Us Here](https://www.upwork.com/o/companies/_~0124e15ff34efb3871/)

---

<div class="post-metadata">

**Author:** ![andre9000](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/andre9000/32/53869_2.png) [@andre9000](https://community.hubspot.com/u/andre9000)\
**Post date:** [August 30, 2018, 1:49pm UTC](https://community.hubspot.com/t/how-to-use-a-variable-for-module-parameter/10002/6 "2018-08-30T13:49:39Z")

</div>

Hey guys,

thanks for your help! Yes, module.link.href was a text field i created for this module.

It was indeed just a syntax error, this worked just fine:

```auto
{% widget_block social_sharing "my_social_sharing" label='Social Sharing', use_page_url=False, link={{module.link.href}}, overrideable=True %}
 {% widget_attribute "twitter" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "twitter", "img_src": "https://static.hubspot.com/final/img/common/icons/social/twitter-24x24.png"}{% end_widget_attribute %}
 {% widget_attribute "linkedin" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "linkedin", "img_src": "https://static.hubspot.com/final/img/common/icons/social/linkedin-24x24.png"}{% end_widget_attribute %}
 {% widget_attribute "facebook" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "facebook", "img_src": "https://static.hubspot.com/final/img/common/icons/social/facebook-24x24.png"}{% end_widget_attribute %}
 {% widget_attribute "email" is_json=True %}{"custom_link_format": "", "enabled": true, "network": "email", "img_src": "https://static.hubspot.com/final/img/common/icons/social/email-24x24.png"}{% end_widget_attribute %}
{% end_widget_block %}

```

The important line:

`link={{module.link.href}}`

Thank you!
