I have just a README.md file I want to publish. There are no other files. Is it not possible to publish this without including a full static site generator to convert it to markdown? Is there no built in capability for this?
Hi, @hanniabu. By default, if you include the base path of
/ in a URL a web server will attempt to display the
index.html file in that directory (the base of the “publish directory”).
If you want to view a different file, you must include that filename in the URL like so:
https://kycisbad.netlify.app/readme.md (<- this URL shows your
Note, you can get the README file to appear at the base URL if you create a redirect like so:
/ /readme.md 200!
There is more documentation about redirects here. The example above is the
_redirects file format. There is also a
netlify.toml format which is equivalent but the syntax differs.
That example above will redirect the path
/ to the readme file so the “pathless” URL (pathless is in quotes because
/ is still a path albeit the shortest one possible for HTTP).
If that doesn’t work as promised or if there are other question, please reply here anytime.
Thanks @luke, I should have clarified. That would resolve my issue if I wanted to display in plain text, but I was wondering if there’s anything built in to take a markdown file and render it as an html file without a static site generator. I know you could do something like this with Github Pages and it renders just as it would if you were looking at the repo, except as a full standalone page.
Hi, @hanniabu. You did clarify and I should have read your question more carefully. About this:
Is there no built in capability for this?
No, there is no built-in capability for this. Netlify is not a static site generator (SSG). We are a service that is intended to support any and all SSGs but not to replace them.
However, there is a solution that is simple to implement!
The simplest way to convert markdown to HTML (that I know of) is to use the command-line utility called
pandoc. Wouldn’t it be nice if
pandoc was installed by default in our build image?
Well, it is!
If you make the following the build command for the site, it will convert file into HTML and with the required name (
pandoc -f markdown -t html -o index.html README.md
If you make that change to the site’s setting here (specifically the “Build command” setting), then the URL below will show the markdown as HTML:
Note, a new build must be triggerred before the change will take effect.
Also, I know you are trying to avoid using an SSG but if you change your mind you might take a look at Hugo:
It is written in Go which makes it quite fast. It converts markdown to HTML much like
pandoc does and there are many themes (both free and paid) for it so you can add some CSS and fonts to your site without needing to be a designer to get a nice looking page layout.
If there are other questions, please let us know.