Using Web Files and Web Templates

Loading

Power Pages (formerly Power Apps Portals) enables makers and developers to build powerful business websites using Dataverse. Two critical components that enable flexibility, customization, and dynamic content delivery in Power Pages are Web Files and Web Templates.

This guide walks you through a detailed, step-by-step explanation of Web Files and Web Templates, their roles, creation process, practical use cases, and best practices.


1. What Are Web Files?

Web Files in Power Pages are used to store and serve static content like:

  • Images (JPG, PNG, SVG)
  • Documents (PDF, DOCX)
  • Scripts (JS files)
  • Stylesheets (CSS files)
  • Fonts and other web assets

These files are stored in Dataverse and made accessible via public URLs, making them suitable for referencing in pages, templates, and themes.

Key Features:

  • Can be stored securely or publicly.
  • Accessible via /webfiles/filename.ext path.
  • Can be tied to a specific website.
  • Indexed by search engines (if public).

2. Creating a Web File

You can create Web Files via the Power Pages Design Studio or the classic Power Apps Portals Management App.

Step-by-step (Design Studio):

  1. Go to Power Pages Studio.
  2. Navigate to the “Media” or “Files” tab.
  3. Click “+ New Web File”.
  4. Provide the following:
    • Name: Friendly name (e.g., LogoImage).
    • Website: Choose your current portal site.
    • Parent Page (optional): Define hierarchy.
    • Partial URL: Define URL slug (e.g., logo.png).
  5. Upload the file content (image, CSS, JS, etc.).
  6. Save and publish.

Access Example:

https://yourportal.powerappsportals.com/webfiles/logo.png

3. Using Web Files in Your Site

You can use Web Files in your HTML or Liquid templates like so:

Images:

<img src="/webfiles/logo.png" alt="Company Logo">

Stylesheets:

<link rel="stylesheet" href="/webfiles/custom-style.css">

JavaScript:

<script src="/webfiles/app-script.js"></script>

4. What Are Web Templates?

Web Templates are reusable HTML structures enhanced with Liquid syntax. These templates are used to build layouts and serve content dynamically.

They allow rendering of:

  • Entire pages (via Page Templates)
  • Sections of pages
  • Reused content structures

Web Templates are stored in Dataverse and referenced by Page Templates.

Key Features:

  • Written in HTML + Liquid.
  • Can include reusable components.
  • Can fetch and display Dataverse data.
  • Used by Web Pages to render dynamic layouts.

5. Creating a Web Template

Via Power Pages Management App:

  1. Go to Portals Management App.
  2. Navigate to Web Templates.
  3. Click “+ New”.
  4. Provide:
    • Name: Template identifier (e.g., MainLayout).
    • Website: Select your site.
    • Source: HTML + Liquid content.

Sample Source:

<!DOCTYPE html>
<html>
<head>
<title>{% block title %}My Site{% endblock %}</title>
<link rel="stylesheet" href="/webfiles/main.css">
</head>
<body>
{% include 'header' %}
{% block content %}{% endblock %}
{% include 'footer' %}
</body>
</html>

6. Linking Web Template to Web Page

To use a Web Template:

  1. Create a Page Template.
    • Type: Web Template
    • Link to your Web Template record.
  2. Create a Web Page.
    • Assign your Page Template.
    • Provide page content.

The content will render inside your Web Template using {% block content %}.


7. Practical Use Cases

Web Files:

  • Host custom styles or JS scripts (custom.css, theme.js).
  • Display static media (images, icons).
  • Offer downloadable PDFs or guides.

Web Templates:

  • Layout engine for entire site.
  • Create master-child page structure.
  • Embed navigation bars, footers, sidebars.
  • Pull Dataverse records using Liquid.

8. Best Practices

For Web Files:

  • Use descriptive names and extensions (header-logo.png, whitepaper-2025.pdf).
  • Minify CSS and JS before upload to improve performance.
  • Use versioning (e.g., style-v2.css) to manage cache invalidation.

For Web Templates:

  • Keep layout clean and use Liquid blocks ({% block %}) wisely.
  • Break down large templates with include.
  • Test template logic with sample Web Pages.
  • Avoid excessive Liquid logic — offload to client-side or automation.

9. Common Pitfalls to Avoid

IssueSolution
Web File not loadingEnsure it’s published and has correct file extension.
404 errorCheck URL and whether the file is linked to the correct site.
Styles not applyingVerify MIME type and relative paths.
Template not renderingEnsure correct mapping via Page Template.

10. Summary

FeatureWeb FileWeb Template
PurposeServe static contentRender HTML/Liquid logic for pages
Stored inDataverseDataverse
UsageMedia, CSS, JS, DocsPage layout, dynamic rendering
Linked ToWeb Pages (indirect)Page Template > Web Page
Supports Logic (Static only) (Uses Liquid template language)

Leave a Reply

Your email address will not be published. Required fields are marked *