Using of "if" to check if the page is homepage

Hello,
I was using Custom Content Shortcode and now I start using Loops and Logic and I sometimes having a hard time doing simple things.
I’m searching for the right code to check if the current page is the homepage or not.
Can you help me with that ?
Thank you
Regards.

Hey Marco, I just started using L&L over the past couple of weeks so I’m by no means an expert yet, but I would achieve that with something like this:

<If check="{Url current}" is value="{Url home}">
  Some markup to be displayed on the home page.
  <Else />
  Some optional markup to be displayed on all other types of pages.
</If>

If you’re struggling to get a hang of the L&L syntax (like writing dynamic attribute values as I did above with the curly braces), you might find this post helpful. Hope that helps get you started!

1 Like

Hello,
This code works as expected.
Thank you very much.
Regards

Just wanted to add a note here - there’s another way to check the current URL route, using the route variable type.

<If route="/">
  Home
<Else />
  Not home
</If>
1 Like

Thanks for this method too :slight_smile:

1 Like