SOLVED: How to make an anchor link?

EY there,
i’m a briks builder noob enthusiast :slight_smile: i’m trying to create an anchor link in a page. Like a link to a container or a module. There is a simple way to do that? Thanks!

2 Likes

Hello @tenentecartina ,

Welcome to the Bricks forum :tada:

Yes, there is. Just set the Link to “External URL” and for the actual link, set it to the ID of the section your want to link to. You can set the ID of the section in the Style > CSS > CSS ID.

Here is also a Loom that explains this:

9 Likes

EY what a quick response. I’m really impressed by bricks and specially by his community. Thanks!

@cristianuibar doesn’t seem to work… if I enter something into the css id field of the element, the element change in a strange way (lose formatting, change size, etc.). Then the anchor doesn’t work in preview mode. On the live page you some code appeared

Screenshot Cattura — ImgBB

Looking at your screenshot that behavior is very weird. Never happened to me, perhaps you added a # inside of the CSS ID section?

I have just tested this again on a new page without any prior anchor links and it works properly for me on v1.2.

Here is another Loom of how I did it:

6 Likes

You perfectly right i messed wiih a custom html tag. Now it works perfectly. Thanks!

1 Like

@cristianuibar Thank you so much for jumping in on this one. Rockstar :muscle:

2 Likes

hi there, another question regarding this topic: is it possible to link to an anchor link on a different page as well?

Sure. It should be the same process. Just use the full url instead of just the #anchor

1 Like

works great, thank you so much for the quick answer!

1 Like

I’m also happy, i was just searching for “how to anchor” and this video was quit and easy =). now i know how to do it, thank you very much =)

2 Likes

Thank you so much Cristian!
I was looking for this a few moments before and your video and instructions are spot-on!
Great community and thank you once again!
Fellow Romanian bricks enthusiast

Hi there,

What about anchors inside elements on a loop?

Is it possible?

Thank you!

Hi @chrisianuibar and thanks for your help here! Is that workaround still needed with the specific url? Because as far as I know, absolute links are bad practice and should be avoided (see end of this site: HTML File Paths). If the domain or the URL changes, I would have to change every single button that links to it… Thought that’s why there is the “internal post” option in the dropdown.

Edit: Okey I just saw that relative paths are allowed here too. Still questioning myself why this is not integrated in the “internal post” option. Or have I overseen something here?

1 Like

Hello @901422183 ,

I don’t think that matters that much. WordPress saves the full permalinks in a GUID field in the DB anyway. So if you ever change your primary domain, you’ll always need to run a full search-replace for the old domain to the new domain. And this search-replace should also fix any such links you have on your buttons.

Also, the “internal post” generates a full URL on the front, as that’s WordPress’s default behavior. It just generates it on the fly.

1 Like

Hi @cristianuibar and thanks for your fast answer! :slight_smile:

I am new to WordPress so thanks for that explanation! In case of an Domain change I understand what you mean, but what if I change the slug of the page I linked to? When done with bricks page selection that would not change anything. When done with a relative/absolute link I would have to change that on each buttons instance… or have I misunderstood something here?

You are correct. For that use-case it’s better to use internal links, as absolute links will not auto-update.

The best rule is to avoid changing slugs once your page is published. It can be shared on other pages/social media etc and you might end up with a 404 for that. However even in that case, if you’re changing a popular page link you should add a 301 redirect for it.

1 Like

Thanks for your help! :slight_smile:

Oh I forgot: How you did the smooth scroll to the anchor in your video?

I know there are multiple ways, but I am interested in yours, that seems to work pretty well with Bricks :slight_smile:

I didn’t do anything else other then what’s in the video.

I guess Bricks has that? Not sure about it :thinking: