# Need to convert html to Markdown

**URL:** <https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099>\
**Category:** support\
**Created:** [April 11, 2016, 7:04pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099 "2016-04-11T19:04:55Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnblood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/johnblood/32/931_2.png) [@johnblood](https://discourse.gohugo.io/u/johnblood)\
**Post date:** [April 11, 2016, 7:04pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/1 "2016-04-11T19:04:55Z")

</div>

I’m looking to convert an old hand-coded HTML site to Hugo. The problem is that it’ll take forever to manually convert the pages from HTML to Markdown. Is there a tool I can use to do this. The only thing I want to keep from the old pages is the content of the and tags. Any ideas or am I in for a long haul?

---

<div class="post-metadata">

**Author:** ![digitalcraftsman](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/digitalcraftsman/32/4142_2.png) [@digitalcraftsman](https://discourse.gohugo.io/u/digitalcraftsman)\
**Post date:** [April 11, 2016, 7:31pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/2 "2016-04-11T19:31:40Z")

</div>

This [converter](https://domchristie.github.io/to-markdown/) should do the job.

---

<div class="post-metadata">

**Author:** ![parsiya](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/parsiya/32/1218_2.png) [@parsiya](https://discourse.gohugo.io/u/parsiya)\
**Post date:** [April 11, 2016, 11:12pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/3 "2016-04-11T23:12:28Z")

</div>

[Pandoc](http://pandoc.org/demos.html) can do it too. See example 12.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [April 12, 2016, 2:05am UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/4 "2016-04-12T02:05:08Z")

</div>

@johnblood  
Assuming you have [homebrew installed](http://brew.sh/):

1. `brew install pandoc`
2. `cd into directory/with/html/files`
3. 

```bash
FILES=*.html
for f in $FILES
do
  filename="${f%.*}"
  echo "Converting $f to $filename.md"
  `pandoc $f -t markdown -o $filename.md`
done

```

Hope that helps. Cheers.

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [April 12, 2016, 6:52am UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/5 "2016-04-12T06:52:43Z")

</div>

In the Windows 7 i use `pandoc` and this .bat file:

html2mark4folder.bat  
`for /r %1 %%f in (*.html) do (pandoc --wrap=none -s -f html -w markdown_mmd+yaml_metadata_block-raw_html -o %%~dpnf.md %%f)`

This file shold be placed in folder `"C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\SendTo"`  
And after that will be possible right-click on any folder, and `send to` it to html2mark4folder.bat to convert all files in the folder.

---

<div class="post-metadata">

**Author:** ![johnblood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/johnblood/32/931_2.png) [@johnblood](https://discourse.gohugo.io/u/johnblood)\
**Post date:** [April 12, 2016, 5:22pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/6 "2016-04-12T17:22:17Z")

</div>

Unfortunately, I have Win7 installed.

---

<div class="post-metadata">

**Author:** ![chreliot](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/chreliot/32/488_2.png) [@chreliot](https://discourse.gohugo.io/u/chreliot)\
**Post date:** [April 12, 2016, 5:43pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/7 "2016-04-12T17:43:02Z")

</div>

Brett Terpstra has a nice online converter at [http://fuckyeahmarkdown.com](http://fuckyeahmarkdown.com)

---

<div class="post-metadata">

**Author:** ![johnblood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/johnblood/32/931_2.png) [@johnblood](https://discourse.gohugo.io/u/johnblood)\
**Post date:** [April 12, 2016, 5:47pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/8 "2016-04-12T17:47:16Z")

</div>

Nice. I gave it try and i looks great. Thanks.

---

<div class="post-metadata">

**Author:** ![rdwatters](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/rdwatters/32/2848_2.png) [@rdwatters](https://discourse.gohugo.io/u/rdwatters)\
**Post date:** [April 12, 2016, 6:57pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/9 "2016-04-12T18:57:08Z")

</div>

@johnblood No worries. You can install and use pandoc on Windows as well:

[http://pandoc.org/getting-started.html](http://pandoc.org/getting-started.html)

Unfortunately, I won’t be of much use with powershell/Windows command line, but it looks like @Mikhail has got that covered for you. Terpstra’s tool seems really cool too, but if you have a ton of pages you might want to hit this with a script recursively. That or just wait until you can [run bash on Windows](http://techcrunch.com/2016/03/30/be-very-afraid-hell-has-frozen-over-bash-is-coming-to-windows-10/?ncid=rss) 😉 .

---

<div class="post-metadata">

**Author:** ![johnblood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/johnblood/32/931_2.png) [@johnblood](https://discourse.gohugo.io/u/johnblood)\
**Post date:** [April 12, 2016, 7:35pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/10 "2016-04-12T19:35:34Z")

</div>

It will be a cold day in H E double hockey stick before I upgrade to Win10. If I have to I’ll switch to Manjaro Linux first. I use Bash on Win7 with Git Bash. Better than sliced bread.

---

<div class="post-metadata">

**Author:** ![parsiya](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/parsiya/32/1218_2.png) [@parsiya](https://discourse.gohugo.io/u/parsiya)\
**Post date:** [April 12, 2016, 8:08pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/11 "2016-04-12T20:08:28Z")

</div>

> [@rdwatters](#):
>
> That or just wait until you can run bash on Windows 😉 .

Doesn’t work yet ☹ .The `timer_create` syscall handler has not been implemented yet.

```
pandoc: timer_create: Invalid argument

```

---

<div class="post-metadata">

**Author:** ![johnblood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/johnblood/32/931_2.png) [@johnblood](https://discourse.gohugo.io/u/johnblood)\
**Post date:** [April 12, 2016, 8:11pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/12 "2016-04-12T20:11:06Z")

</div>

My philosophy is why risk goofing up a Windows install that works (those licences cost $$$$$$$$$$$$$$$$$$$$$$$$$) when you can buy a cheap laptop and install Manjaro.

---

<div class="post-metadata">

**Author:** ![johnblood](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/johnblood/32/931_2.png) [@johnblood](https://discourse.gohugo.io/u/johnblood)\
**Post date:** [April 15, 2016, 3:13am UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/13 "2016-04-15T03:13:10Z")

</div>

I tried to use the .bat files, but it did not work. When I try to use it, the command prompt appeared briefly and disappeared. When I tried to convert a test file from the command prompt (`pandoc -s earlyyears.html -o earlyyears.md`). I got this error:

`pandoc.exe: Cannot decode byte '\xa9': Data.Text.Internal.Encoding.Fusion.stream Utf8: Invalid UTF-8 stream`.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [April 15, 2016, 6:17am UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/14 "2016-04-15T06:17:02Z")

</div>

> [@johnblood](#):
>
> Data.Text.Internal.Encoding.Fusion.stream Utf8

> <https://tex.stackexchange.com/questions/97843/how-to-interpret-message-invalid-utf-8-stream-when-trying-to-convert-a-tex-fil>

---

<div class="post-metadata">

**Author:** ![meker12](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@meker12](https://discourse.gohugo.io/u/meker12)\
**Post date:** [May 24, 2018, 6:37pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/15 "2018-05-24T18:37:03Z")

</div>

Thanks for this. Extremely useful 🙂

---

<div class="post-metadata">

**Author:** ![Mikhail](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mikhail/32/1138_2.png) [@Mikhail](https://discourse.gohugo.io/u/Mikhail)\
**Post date:** [May 24, 2018, 6:45pm UTC](https://discourse.gohugo.io/t/need-to-convert-html-to-markdown/3099/16 "2018-05-24T18:45:28Z")

</div>

> [@meker12](#):
>
> Thanks for this. Extremely useful 🙂

See also: [Useful cmd for windows-users. Converter page.md to page/index.md and reverse; slug to filename and etc](https://discourse.gohugo.io/t/useful-cmd-for-windows-users-converter-page-md-to-page-index-md-and-reverse-slug-to-filename-and-etc/4756)
