#hi can i use html files along with markdown files for my content collection?i got few html files rn

9 messages · Page 1 of 1 (latest)

vernal cradle
#

hi can i use html files along with markdown files for my content collection?
i got few html files rn that i would like to turn into a content collection without much hassle of rewriting them into markdown but then be able to add markdown files later

willow surgeBOT
#

Hi @vernal cradle. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

You can mix Markdown and other data formats in a single (non-legacy) content collection, but the docs only list these as supported entry file types: Markdown, MDX, Markdoc, YAML, TOML, JSON when using the glob() loader. [Content collections; Defining loader]

There is no mention of .html files being supported as collection entries in the content collections docs, and the only documented uses of .html are:

Because .html is not listed as a supported collection entry type, I can’t confidently say you can put .html files directly into a content collection alongside Markdown. The knowledge sources don’t describe such a setup.

What you can do with the information we have:

  • Keep your existing .html files as HTML pages/components in src/pages/ or as imported components. [HTML components; HTML pages]
  • Start a content collection for new content using Markdown/MDX/etc. and grow it over time. [Content collections]
#

If you specifically need those existing HTML files to be entries in a content collection, the docs provided here don’t show a supported way to do that without converting them to one of the supported formats.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@vernal cradle Kapa.ai is still learning and improving, please let me know how I did by reacting below.

vernal cradle
#

oh and can i use html in md

#

@willow surge oh and can i use html in md

willow surgeBOT
#

Let me check the knowledge base for you again. One moment! :books:

#

Yes, you can use (some) HTML in .md files, but behavior depends on what you’re doing:

  • Standard Markdown in Astro: You can include HTML elements directly in Markdown pages/content, e.g. <p>HTML elements</p> alongside Markdown. [Individual pages]

  • Images exception: For local images in src/, you must use Markdown syntax ![](); <img> is only supported for public/ or remote images. [Images in Markdown]

  • Markdoc integration: If you’re using @astrojs/markdoc, HTML is not recognized by default. You must enable it with allowHTML: true in the Markdoc integration config to mix HTML with Markdoc content. [Markdoc allowHTML]

So: plain Astro Markdown supports inline HTML, with some special rules (like images); Markdoc needs allowHTML: true to behave similarly.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: