create_content
Create new content items in LightCMS using templates, with support for wikilinks, snippets, hashtags, and Markdown to build structured website pages.
Instructions
Create a new content item. Requires a template_id, title, slug, and the data fields defined by the template.
Workflow:
Call list_templates to find the right template and its field names.
Create the content with data matching those fields.
Call publish_content to make it live (or set published=true here to do both in one step).
Set use_header=true, use_footer=true, use_theme=true for pages that should use the site layout. Always include version_comment to make history readable.
Content data fields support rich markup features:
[[Wikilinks]] and [[Page Title|display text]] — link to other pages by title or path; auto-update when paths change
[[include:snippet-name]] — embed a named snippet inline (reusable callouts, CTAs, disclaimers)
#hashtags — mention #tagname anywhere to automatically tag the page
Markdown fields (type "markdown") — GitHub Flavored Markdown converted to HTML at publish time Templates can use {{.lc_toc}} in their HTML layout to inject an auto-generated table of contents.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No | Content category for collections | |
| data | Yes | Template field values,required | |
| folder_path | No | Folder path (e.g., /blog) | |
| meta_description | No | SEO meta description | |
| og_image | No | Open Graph image URL | |
| published | No | Publish immediately | |
| raw_mode | No | Use raw HTML mode | |
| slug | Yes | URL slug for the content,required | |
| tags | No | Tags for lc:query index pages (e.g. ['AI & Machine Intelligence', 'Generative AI']) | |
| template_id | Yes | Template ID (MongoDB ObjectID),required | |
| title | Yes | Content title,required | |
| use_footer | No | Include site footer | |
| use_header | No | Include site header | |
| use_theme | No | Apply site theme/layout | |
| version_comment | No | Optional comment describing this version |
Implementation Reference
- static/js/chat-widget.js:294-326 (handler)The handleEvent function processes chat events, including 'token' (streaming response) and 'sources' (retrieved context). It dynamically updates the UI to display the generated answer and links to sources.
function handleEvent(evt) { if (evt.type === 'token' && evt.text) { rawAnswer += evt.text; ensureAnswer().innerHTML = renderMarkdown(rawAnswer); body.scrollTop = body.scrollHeight; } else if (evt.type === 'sources') { removeLoading(); var results = evt.results || []; if (results.length === 0 && !answerEl) { body.innerHTML = '<p class="lc-no-results">No results found. Try rephrasing your question.</p>'; return; } if (results.length > 0) { sourcesEl = document.createElement('div'); sourcesEl.className = 'lc-sources'; var html = '<div class="lc-sources-label">Sources</div>'; for (var i = 0; i < results.length; i++) { var r = results[i]; html += '<a class="lc-result" href="' + escHtml(r.url) + '">' + '<span class="lc-result-arrow">↗</span>' + '<span class="lc-result-title">' + escHtml(r.title) + '</span>' + '</a>'; } sourcesEl.innerHTML = html; body.appendChild(sourcesEl); body.scrollTop = body.scrollHeight; } } else if (evt.type === 'done') { sendBtn.disabled = false; input.value = ''; input.focus(); } }