In website development, fragments are an essential concept that enable flexible and efficient content management. As a powerful content management system, Empire CMS offers several fragment types that developers can use in different scenarios. This article explores five common fragment types—text, link, image, audio, and video fragments—and provides code examples to help you better understand how to use them.
The text fragment is one of the most basic and widely used fragment types, designed to display textual content. It can contain plain text or simple HTML elements such as paragraphs, titles, and lists, allowing for versatile content layouts. Administrators can easily create, edit, and embed text fragments into templates via the Empire CMS backend, improving reusability and control over content.
<div class="text-fragment"> <h2>Welcome to Our Website</h2> <p>This is an example of a text fragment where you can enter any text content you wish.</p> </div>
Link fragments are used to display hyperlinks that lead to other pages or external websites. They can be either text or image links, providing convenient navigation for users. By using link fragments strategically, you can enhance interactivity and improve your site's SEO performance.
<div class="link-fragment"> <a href="https://www.example.com">Click here to visit the sample site</a> </div>
Image fragments are used to display visual content such as product photos, banners, or icons. With image fragments, developers can flexibly manage and call different image resources to maintain consistency and visual appeal across the website.
<div class="image-fragment"> <img src="example.jpg" alt="Image Fragment Example"> </div>
Audio fragments allow you to embed audio files—such as music or podcasts—directly into your web pages. This feature adds an auditory dimension to your website, improving the overall user experience through interactive audio playback.
<div class="audio-fragment"> <audio controls> <source src="example.mp3" type="audio/mp3"> </audio> </div>
Video fragments are used to embed video content on your website, making your pages more engaging and interactive. Whether it's a promotional video or a tutorial, video fragments make it simple to integrate multimedia into your design.
<div class="video-fragment"> <video controls> <source src="example.mp4" type="video/mp4"> </video> </div>
Each of the five fragment types in Empire CMS has its own unique role and advantages. By making full use of these fragment types, developers can enhance content manageability, streamline website structure, and provide a better user experience. Mastering the use of fragments is key to building an efficient and dynamic CMS-driven website.