Magento, how to add static url link in Block

Magento, how to add static url link in Block

September 18, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento, how to add static url link in Block

Adding Static URLs to Magento Blocks: A Step-by-Step Guide

Are you facing challenges while trying to add static URL links within your Magento blocks? You’re not alone! In this post, we’ll guide you through the process of adding a URL link to a customized CMS page using XML files.

Understanding the Current Approach

First, let’s break down the current approach you’ve shared:

<action method="addLink"
        translate="label title"
        module="catalog">
    <label>My Account</label>
    <url helper="customer/getAccountUrl" />
    <title>My Account</title>
</action>

This code adds a link called “My Account” using the customer/getAccountUrl helper from the catalog module. However, you’re right in noting that this method retrieves URLs dynamically based on the module’s configuration.

To add a URL to a static CMS page, we need to use Magento’s built-in functionality for managing static pages. Here’s how:

  1. Identify your CMS page ID: First, you need to find or create the CMS page you want to link to in the Magento admin panel under Content > Pages.

  2. Use the cms/getLink helper: Instead of using a module-specific URL like customer/getAccountUrl, we’ll use the cms/getLink helper. This helper retrieves the URL for a specific CMS page based on its ID.

Here’s an example of adding a link to a CMS page with ID 10:

<action method="addLink"
        translate="label title">
    <label>My Custom Page</label>
    <url helper="cms/getLink" paramId="10"/>
    <title>My Custom Page</title>
</action>

In this code, replace 10 with the actual ID of your CMS page. The paramId attribute specifies which CMS page to link to.

Best Practices for Adding URLs

While working with Magento blocks and URLs, here are some best practices to keep in mind:

  • Use Magento’s built-in helpers where possible to ensure compatibility across different versions.
  • Avoid hardcoding URLs directly into your XML files. Instead, use the appropriate helper functions.
  • Ensure that your CMS pages are published before attempting to link to them.
  • Test your links thoroughly on both the frontend and backend after making changes.

Concluding Our Guide

Adding static URL links to Magento blocks is a common task with a straightforward solution. By following our guide and using Magento’s built-in cms/getLink helper, you can easily create functional links to your CMS pages within XML files.

Remember that proper testing and adherence to Magento’s best practices will help ensure the stability and security of your e-commerce platform.

For more in-depth tutorials on Magento development and tips for optimizing your store’s performance, feel free to explore our Magento Development Services at Laravel Company.

Catalog Extensions Admin Configuration

Our network