# Button's link doesn't work

**URL:** <https://community.hubspot.com/t/buttons-link-doesnt-work/79151>\
**Category:** CMS Development\
**Tags:** starter\
**Created:** [April 12, 2023, 10:59am UTC](https://community.hubspot.com/t/buttons-link-doesnt-work/79151 "2023-04-12T10:59:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RLanzani](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@RLanzani](https://community.hubspot.com/u/RLanzani)\
**Post date:** [April 12, 2023, 10:59am UTC](https://community.hubspot.com/t/buttons-link-doesnt-work/79151/1 "2023-04-12T10:59:30Z")

</div>

Hi,

I just used this code to create a button that has an alignment opition (source: [post link](https://community.hubspot.com/t5/CMS-Development/how-to-center-align-buttons/td-p/419932) 😞

{{ require\_css }}  
\<style\>  
.horz-{{ module.button\_position }}{  
display:flex;  
flex-direction:column;  
flex-wrap:no-wrap;  
justify-content:flex-start;  
align-items: {{ module.button\_position }};  
align-content:center;  
}  
\</style\>  
{{ end\_require\_css}}  
{% if module.button\_link.url.type is equalto ‘EMAIL\_ADDRESS’ %}  
{% set href = ‘mailto:’ ~ module.button\_link.url.href %}  
{% elif module.button\_link.url.href == ‘/’ %}  
{% set href = module.button\_link.url.href %}  
{% else %}  
{% unless (module.button\_link.url.href is string\_containing ‘//’) or !module.button\_link.url.href %}  
{% set href = ‘//’ ~ module.button\_link.url.href %}  
{% else %}  
{% set href = module.button\_link.url.href || ‘’ %}  
{% endunless %}  
{% endif %}

{% set rel = (module.button\_link.open\_in\_new\_tab ? 'noopener ’ : null) ~ (module.button\_link.no\_follow ? ‘nofollow’ : null) %}  
\<div class=“horz-{{module.button\_position}}”\>  
\<{% if module.button\_options.button\_link\_toggle == true %}a href=“{{ href }}” {% else %}button {% endif %} class=“button{% if module.style.button\_type == ‘secondary’ %} button--secondary{% elif module.style.button\_type == ‘simple’ %} button--simple{% endif %}{% if module.style.button\_size == ‘small’ %} button--small{% elif module.style.button\_size == ‘large’ %} button--large{% endif %}{% if module.button\_icon.icon\_position == ‘right’ %} button--icon-right{% endif %}”  
id=“button\_{{ name }}”  
{% if module.button\_link.open\_in\_new\_tab %}target=“\_blank”{% endif %}  
rel=“{{ rel }}”\>

{% if module.button\_options.button\_icon\_toggle == true and module.button\_icon.icon\_field.unicode %}  
{% icon  
extra\_classes=‘button\_\_icon’  
name=‘{{ module.button\_icon.icon\_field.name }}’  
purpose=‘decorative’  
style=‘{{ module.button\_icon.icon\_field.type }}’  
unicode=‘{{ module.button\_icon.icon\_field.unicode }}’  
%}  
{% endif %}  
{{ module.button\_text }}

\</{% if module.button\_options.button\_link\_toggle == true %}a{% else %}button{% endif %}\>  
\</div\>

Now i have a new problem: every time i tried an internal or external link, it doesn’t work and i remain on the same page.

I don’t know how to resolve it.

Im gonna attach here a screenshot of the code

 ![Screenshot 2023-04-12 at 09.47.44.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/2X/f/f3954cda6c3dd1547c27a739346c7d6d72d363f0.jpeg)

 ![Screenshot 2023-04-12 at 09.49.57.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/1/1c1b106944281bc8437c573e6fa0d359b46e5838.png)  
:

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [April 13, 2023, 2:42pm UTC](https://community.hubspot.com/t/buttons-link-doesnt-work/79151/2 "2023-04-13T14:42:50Z")

</div>

Hi, @RLanzani 👋 Thanks for reaching out. It looks like you are using a solution provided by @Anton Let’s see if they have any additional feedback. Or if any of our other community members has a different way to approach your button project.

Thanks for taking a look! — Jaycee

Thanks for

---

<div class="post-metadata">

**Author:** ![RaggarP](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@RaggarP](https://community.hubspot.com/u/RaggarP)\
**Post date:** [July 13, 2023, 1:17pm UTC](https://community.hubspot.com/t/buttons-link-doesnt-work/79151/3 "2023-07-13T13:17:16Z")

</div>

Hi,

Im facing the same problem as you: “every time i tried an internal or external link, it doesn’t work and i remain on the same page.”

Did you find any soultion to this?
