Page code: HTML, CSS and JavaScript of a page
For users
What it is for
Every CMS page has its own code: HTML (the content), CSS (styles for this page) and JS (script for this page). Use page code for one page's layout or behaviour. For code that every page needs, use Site code.
Where
SufiCMS → Pages (/panel/admin/cms/pages) → open the page → page menu → Code (fa: «کد»). The dialog has HTML, CSS and JS tabs.
Before you start
- Page CSS only works when Site settings (
/panel/admin/cms/site) → Allow page-level CSS («اجازه CSS سطح صفحه») is on.
Steps
- Open the page in the editor and reload it once.
- Open Code. Wait until the code has loaded; the drawer can open empty for a moment. Never save an empty drawer.
- Edit one tab, then save before switching tabs. Switching HTML → CSS → HTML drops unsaved HTML edits.
- Re-open the page and compare the saved code with what you pasted.
- Publish each language you changed (see Translations).
- Check the live page in a private window. The editor preview does not run page JS.
What the CMS changes or removes when you save
| You put in | What happens |
|---|---|
| Page CSS longer than 16,000 characters | Cut at 16,000 characters, no warning |
<style> block inside the HTML |
Removed |
Inline style="..." with clamp(), calc() or max(), and gap |
That declaration is dropped silently; plain values stay |
<canvas>, form controls such as <select>, data: images |
Removed by the sanitizer |
| Any element | Gets data-cms-section / data-cms-id attributes (stored HTML roughly doubles) |
Page HTML and JS are stored in full (tested with about 70,000 characters).
Tips
- Page JS is shared by all languages of the page. Saving JS in one language changes it in every language. Don't put translated text in JS; read it from the page HTML (for example a
data-*attribute) instead. - Write language-specific CSS with
:dir(),[dir]or[lang]selectors so one stylesheet works for all languages. - Public pages have
<base href="/">. In-page links need the language path, for example/fa#pricing, not just#pricing. - Large stylesheets: keep page CSS under 16,000 characters and put shared styles in Site CSS.
- Don't rebuild what the platform already has (menus, brand/logo, language switcher, page title/SEO) in page code. Use Menus, Branding and Page settings.
- Each language version keeps up to 50 revisions («نسخهها»).