# Development

Pages are developed, maintained, and deployed by Ubidots **users** to create fully custom visualizations that meet requirements not addressed natively by the platform.

A Page uses a specific set of files. These files define the Page settings, such as references to local files or CDN-hosted CSS and JavaScript (JS) libraries. They also define the Page logic and overall functionality. The file structure is shown below:

```
├── manifest.toml
├── script.js
├── body.html
├── style.css
├── static
│   ├── some_files_or_folders  
```

{% hint style="warning" %}
This file structure is required. Include all listed files so the Page works correctly and can be deployed.
{% endhint %}

{% hint style="info" %}
**Allowed file extensions in the static folder**

.csv, .css, .gif, .html, .ini, .jpeg, .jpg, .js, .json, .jsx, .log, .md, .mjs, .png, .rst, .svg, .ts, .tsv, .tsx, .toml, .txt, .webp, .xml, .yaml, .yml
{% endhint %}

## manifest.toml

The manifest file defines the Page settings and references to local or external CSS and JS resources. It includes:

* Name of the page.
* Keywords.
* Description.
* Path to local files.
* Local and third-party JS libraries.
* Local and third-party CSS stylesheets.

A typical Page manifest includes the following keys and values.

| Key                         | Type                    | Description                                                                                                                                                 |
| --------------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| name                        | String                  | Name of the page                                                                                                                                            |
| keywords                    | Comma-separated strings | Added in a `<meta>` tag within the HTML document's `<head>`.                                                                                                |
| description                 | String                  | Added to the HTML document's `<head>` within a `<meta>` tag.                                                                                                |
| static\_paths               | List of strings         | Paths to folders containing local files.                                                                                                                    |
| js\_libraries               | List of sets            | References local JS files. These files are included with a `<script>` tag in the HTML document's `<head>`.                                                  |
| js\_thirdparty\_libraries   | List of sets            | References CDN-based JS libraries. These files are included with a `<script>` tag in the HTML document's `<head>`.                                          |
| css\_libraries              | List of sets            | References local CSS stylesheets. These files are included with a `<link rel="stylesheet">` tag in the HTML document's `<head>`.                            |
| css\_thirdparty\_libraries  | List of sets            | References CDN-based CSS stylesheets. These files are included with a `<link rel="stylesheet">` tag in the HTML document's `<head>`.                        |
| link\_libraries             | List of sets            | References local resources. These files are included with a [`<link>`](https://www.w3schools.com/tags/tag_link.asp) tag in the HTML document's `<head>`.    |
| link\_thirdparty\_libraries | List of sets            | References external resources. These files are included with a [`<link>`](https://www.w3schools.com/tags/tag_link.asp) tag in the HTML document's `<head>`. |

With that in mind, a manifest file looks like this:

{% hint style="warning" %}
The `manifest.toml` file must start with the `[page]` section header.
{% endhint %}

```toml
[page]
name = "Page name"
keywords = "test,validation"
description = "Page for testing purposes."
static_paths = ["static"]

js_libraries = [{src="script.js", type="module", defer="", crossorigin=""}]
js_thirdparty_libraries = [
    {src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/echarts.min.js"},
    {src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"}
]

css_libraries = [{href="style.css", crossorigin=""}]
css_thirdparty_libraries = []

link_libraries = [{href="static/style_link.css", type="font", crossorigin=""}]
link_thirdparty_libraries = []
```

The example below shows how Ubidots interprets the Page name, keywords, and description, and adds them to the Page HTML document's `<head>` automatically.

```html
<head>
     <title>Page name</title>
     <meta name="keywords" content="test,validation"/>
     <meta name="description" content="Page for testing purposes."/>
</head>
```

Read the following section to learn about how Ubidots interprets the libraries keys.

### Libraries syntax

This applies to the `List of sets` keys. These keys contain lists where each element follows one of the forms below:

<table><thead><tr><th width="235">Key</th><th width="325">Form</th><th>Description</th></tr></thead><tbody><tr><td><p>– js_libraries</p><p>– js_thirdparty_libraries</p></td><td><pre><code>{src=&#x3C;URL|path>, [ATTRIBUTES]}
</code></pre></td><td><code>[ATTRIBUTES]</code> can be any valid attribute for HTML's <a href="https://www.w3schools.com/tags/tag_script.asp"><code>&#x3C;script></code></a> tag.</td></tr><tr><td><p>– css_libraries</p><p>– css_thirdparty_libraries</p><p>– link_libraries</p><p>– link_thirdparty_libraries</p></td><td><pre><code>{href=&#x3C;URL|path>, [ATTRIBUTES]}
</code></pre></td><td><code>[ATTRIBUTES]</code> can be any valid attribute for HTML's <a href="https://www.w3schools.com/tags/tag_link.asp"><code>&#x3C;link></code></a> tag.</td></tr></tbody></table>

Ubidots interprets these library keys and adds them to the Page HTML document's `<head>` as follows:

```html
<head>
    <!-- js_libraries
    TOML: {src="script.js", type="module", defer="", crossorigin=""}
    Translates to:
    -->
    <script src="UBIDOTS_CDN_URL/script.js" type="module" defer crossorigin></script>
    
    <!-- js_thirdparty_libraries
    TOML: {src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/echarts.min.js"}
    Translates to:
    -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.4.3/echarts.min.js"></script>
    
    <!-- css_libraries
    TOML: {href="style.css", crossorigin=""}
    Translates to:
    -->
    <link href="UBIDOTS_CDN_URL/style.css" crossorigin rel="stylesheet"/>
    
    <!-- css_thirdparty_libraries
    TOML: {href="https://fonts.googleapis.com/css?family=Roboto:300i,400&display=swap", crossorigin=""}
    Translates to:
    -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:300i,400&display=swap" crossorigin rel="stylesheet"/>
    
    <!-- link_libraries
    TOML: {href="static/style_link.css", type="font", crossorigin=""}
    Translates to:
    -->
    <link href="UBIDOTS_CDN_URL/static/style_link.css" type="font" crossorigin rel="stylesheet"/>
    
    <!-- link_thirdparty_libraries
    TOML: {href="https://fonts.googleapis.com/css?family=Roboto:310i,410&display=swap", type="font", crossorigin=""}
    Translates to:
    -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:310i,410&display=swap" type="font" crossorigin rel="stylesheet"/>
</head>
```

## script.js

This file contains the Page JS logic. It can:

* Use the `js_libraries` and `js_thirdparty_libraries` specified in the `manifest.toml` file.
* Access the [Ubidots built-in JS library](/dashboards-and-widgets/html-canvas/built-in-library.md).

## body.html

This file defines the HTML body of the page. Include only the contents of `<body>`. Ubidots then inserts that content into the actual Page body. For example:

Your code:

```html
<div id="main"></div>
```

Loaded in the page:

```html
<body>
    <div id="main"></div>
</body>
```

{% hint style="danger" %}
Do not include `<head>` in `body.html`. Ubidots creates it from `manifest.toml`.
{% endhint %}

## style.css

This is the main stylesheet for your page. You can also import more styles from local files in the `static_paths` folder or from external resources.

## static folder

In this folder, you can upload additional CSS or JS files, nested folders, or other file types. Use it to include proprietary libraries or resources such as fonts, icons, and images needed to render the page.\
You can use these files in two ways within the Page:

1. Reference them in the `manifest.toml` file. Ubidots then imports them as described in the [Libraries syntax](#libraries-syntax) section.
2. Access them through the page's public `staticUrl`. See below.

To access files in the `/static` folder — or another folder referenced in `manifest.toml` — from `script.js`, use:

```
const staticPageUrl = window.staticUrl;
const imageUrl = `${staticPageUrl}/<path>/<fileName>.<extension>`;
```

Here, `<path>` is the path referenced in `manifest.toml`, such as `static`. Then `<fileName>` and `<extension>` point to the specific file inside that folder.

{% hint style="info" %}
**Allowed file extensions**

.csv, .css, .gif, .html, .ini, .jpeg, .jpg, .js, .json, .jsx, .log, .md, .mjs, .png, .rst, .svg, .ts, .tsv, .tsx, .toml, .txt, .webp, .xml, .yaml, .yml
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.ubidots.com/apps/pages/development.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
