Import markdown file

Hey. I want to import a .md file in the streamlit application.

In tried this approach:

from pathlib import Path
import streamlit as st

def read_markdown_file(markdown_file):
    return Path(markdown_file).read_text()

intro_markdown = read_markdown_file("introduction.md")
st.markdown(intro_markdown, unsafe_allow_html=True)

I get the error that the introduction.md file cannot be found even though it is in the same folder as the main.py.
Any ideas?

Hi @Isa,

I was unable to reproduce the error on my end. It successfully read and displayed the markdown file :confused:

Have you tried to pass the absolute path to the file instead of a relative path? e.g:

read_markdown_file("path/to/project/introduction.md")

Best, :balloon:
Snehan