Migrating away from markdown


(Matthewp) #1

I have a site that uses the markdown directive and I would like to migrate away from that. I would like to generate all of the pages as HTML so that I will have those. Before Caddy 0.9 there was a way to statically generate the pages, but there is not any more.

How does one then migrate away from markdown? Is crawling the only possibility?


(Paul Hodges) #2

Just google “markdown to html” and you’ll find vast numbers of converters, both online and installable.


(Matt Holt) #3

Sounds like you basically want a static site generator. Hugo is good at that!


(Matthewp) #4

Hugo doesn’t generate the exact same HTML that caddy’s markdown does. Does Caddy store the HTML in a temp folder or something so I can start the server and then copy the HTML it generates or something?


(Matt Holt) #5

It might be easiest to just add a ioutil.WriteFile() call into Caddy’s markdown rendering code, if you need Caddy to render it… no, markdown is served from memory I’m pretty sure.


(Matthewp) #6

Thanks, that worked fine. For anyone else wanting to do the same, this is what I did. About right here I added:

fn := htmlfile(r.URL.Path)
fmt.Println(fn)
err = ioutil.WriteFile(fn, html, 0644)

with htmlfile being this function:

func htmlfile(p string) string {
	if(p == "/") {
		return "tmp/index.html"
	} else {
		sl := s.Split(p, "/")
		fn := sl[len(sl)-1]

		sl = s.Split(fn, ".md")
		fn = sl[0]

		return "tmp/" + fn + ".html"
	}
}

Disclosure, not a Go programmer, but it did the trick. Had to click on all of the links but writing a crawler wouldn’t be too hard.


(system) #7

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.