Magento Static block URL

Magento Static block URL

October 10, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento Static block URL

Resolving Magento Static Block URLs for HTTPS

When creating static blocks in Magento, you might face issues with URL formatting switching between HTTP and HTTPS depending on the current environment. This is particularly common when using {{store_url=}} in your block content.

Understanding the Issue

The {{store_url=}} variable provided by Magento only generates the base URL of the store. It does not account for protocol changes (HTTP vs HTTPS) based on the current secure connection status. As a result, if you’re using this variable in a static block and your site has both HTTP and HTTPS URLs active, the links will switch between protocols accordingly.

Analyzing the Code

Let’s examine the provided code:

<a title="Click here for more information" href="{{store_url=about-us}}" target="_self">About Us</a>

This code creates a hyperlink with the “About Us” text pointing to the URL returned by {{store_url=about-us}}. The problem lies in the hardcoding of protocol switching based on the current connection.

The Solution: Magento’s Secure Base URL

To resolve this issue, we need to use a combination of Magento’s base URL functions that account for secure connections. Let me guide you through the solution:

  1. Understanding Mage::getBaseUrl(): This function returns the base URL of the current store with an optional parameter indicating whether it should be in the HTTP or HTTPS format.

  2. Using the Function Correctly: To ensure your URLs always use the secure connection, apply the following function within your static block content:

<a title="Click here for more information" href="{{store direct_url='about-us'}}" target="_self">About Us</a>

Here’s how it works:

  • We replace {{store_url=}} with {{store direct_url=}}
  • The direct_url parameter tells Magento to generate the URL directly, bypassing any protocol switching logic
  • This ensures that regardless of the current connection status (HTTP or HTTPS), the generated URL will use the secure protocol

Best Practices: Secure URLs in Magento

  • Consistently use {{store direct_url=}} in your static blocks and CMS pages to ensure all links are secure.
  • Avoid mixing HTTP and HTTPS URLs within the same page to prevent mixed content warnings in modern browsers.

Conclusion: Resolving Static Block URL Issues

By properly utilizing Magento’s base URL functions, specifically {{store direct_url=}}, you can maintain consistent and secure URL formatting across your site. This simple change ensures that regardless of whether a user is connected via HTTP or HTTPS, the links within your static blocks will always be in the secure format.

Remember to update all relevant static block content with this corrected syntax for a consistent user experience and improved security.

For more advanced Magento configuration tips and best practices, check out our detailed guides on Magento Configuration Optimization at Laravel Company.

Customers Errors CLI

Our network