Next.js 15 Markdown Boilerplate

45 pointsposted 6 days ago
by dtedesco1

47 Comments

palmfacehn

5 days ago

Next.js and React are the problem here. Adding another layer adds complexity. To simplify, you should remove complexity. To comprehensively address the problem you should strike at the root causes, rather than adding yet another layer of duct tape.

dtedesco1

5 days ago

I agree, but it's just too difficult to get away from the React ecosystem...

Do you have suggestions on a better alternative?

politelemon

2 days ago

It is not difficult to get away from that ecosystem, they simply need to not be included. It is in fact more work to include them and introduced unnecessary complexity.

Several markdown to html generators exist that are well established which simply use the base languages: node, python, go, etc. Instead of using a framework that isn't suited to the task, they focus on structure and features and work on that. By working on the features, structure, and grammar, the tooling will emerge.

lelanthran

2 days ago

> I agree, but it's just too difficult to get away from the React ecosystem...

Why? What specifically are you using for "website with markdown" that needs React?

> Do you have suggestions on a better alternative?

Yes.

1. For turning markdown into html on the server (i.e. render the HTML on the server and then deliver it) use pandoc. I use it like this for my blog: https://gist.github.com/lelanthran/2634fc2508c93a437ba5ca511...

2. For turning markdown into html on the client, write a custom component that parses the markdown into DOM nodes allowing the page author to simply do `<dynamic-markdown remote-src=some/path/to/page.md>`. You can even use one of the many existing Vanilla JS libraries to do this within the custom component.

In either of those two options above, what value does React add?

pvtmert

2 days ago

Why not using marked.js or equivalent, plugging it with a Fetch API instead?

example:

  <html>
  <head><title>hello</title></head>
  <body>
  <main id=root ></main>
  <script src=./marked.min.js async defer ></script>
  <script>
  async function load() {
    let element = document.querySelector("main#root");
    await fetch("./index.md") 
      .then(resp => resp.text())
      .then(text => marked(text, { ... }))
      .then(html => {
        element.innerHTML = html;
      });
  }
  window.onload = load;
  </script>
  </body>
  </html>
since it directly injects the resulting html, you may set "unsafe HTML" option in marked (or markdown.js) and include <title> tags within your markdown document. this will _also_ rewrite the browser title(s)

> edit: formatting

taude

2 days ago

https://htmx.org/. - for smaller sites. Likely the type of site you'd make content in markdown and have it transformed?

lawn

2 days ago

You could make it simpler in Python, Go, PHP, Rust, Elixir, Haskell, Ruby, and even in JavaScript if you want to step outside the JS ecosystem.

Just try to make something without React and you light see the light. It's actually not difficult.

arandomhuman

2 days ago

I was expecting a sort of MD to HTML conversion since it's hard to think of a simpler way of doing this. I don't see how react or nextjs constitutes this being easy or simple unless you're targeting folks with domain knowledge with those ecosystems.

pseudosavant

2 days ago

I was expecting a really simple static-site generator too, but this idea is interesting as well. The heavyweight aspect of using Next/React dampen things a bit.

If it is a client-side solution, I'm imagining a single index.html file (with inline JS/CSS) that you could have a content/ or markdown/ child folder for. The HTTP server would have directory listing on for that folder. The index.html file enumerate/fetch the markdown in the content and folder and render it. You could route using the URL hash.

No build process. Just a single file + your markdown content. Maybe I just like this kind of stuff (https://github.com/pseudosavant/player.html, https://github.com/pseudosavant/folder.api)? So tempted to vibe-code an example...

pvtmert

2 days ago

This is exactly how my (personal) page(s) work! I wrote it pre-covid.

Initially I was using the hash as you suggested, but the redirect/404 was flaky when I use github-pages as the host, hence I reverted to the query-string (? or search) as it creates a complete refresh. Which allows me to set up "virtual" routes like `/blog`.

Topping with worker/service worker, it is quite robust!

Link: https://mert.akeng.in/

JohnKemeny

2 days ago

Agreed. Pandoc with some webpage template (bootstrap).

adamgordonbell

2 days ago

Looks cool.

But isn't Hugo or Jekyll the easy way to turn markdown into a website?

Jekyll was literally made by github to have a simple way to turn a markdown page into a github pages site. Wasn't it?

Just put an index.md in the root of a empty repo and flip the right flags in Github and have a static site.

switz

2 days ago

I published a more batteries-included sample RSC+MDX blog extracted out of my own personal blog[0]

You can see it here: https://rsc-mdx-blog.saewitz.com

It has server-rendered mdx, client components, inline footnotes, layout bleeding, server-rendered code syntax highlighting, content-collections, and opengraph image generation. It can be rendered fully static or from a server. If you choose to deploy it as static, the "server"-rendering just happens at build-time.

It's a really decent starting point for someone who wants an efficient, lean, powerful, and flexible blog.

It is open sourced here: https://github.com/switz/rsc-mdx-blog-starter

[0] https://saewitz.com

belmead

2 days ago

Neato indeed, but the color contrast for copy and other elements doesn't meet AA accessibility standards (even my young-ish eyes have a bit of trouble). Still, this is in line with a project I've been meaning to do, so this is pretty great stuff.

bananapub

2 days ago

obviously it's deeply unhinged to suggest this is method is easy, or indeed a good idea at all, but if you want actually easy ways to do this, Zola and eleventy are both actually quite easy and will get you OK looking static html output in a few minutes of effort.

pavel_lishin

2 days ago

True, and I was going to comment the same thing, but I think this project is about explicitly allowing React components - which presumably means some level of interaction higher than eleventy can provide.

KronisLV

a day ago

Nobody mentioned it yet, so I really liked mdbook: https://wofwca.github.io/mdBook/cli/init.html

The output is just a bundle of files for your web server of your choice, supports good navigation with the sidebar, custom theming if you need it (but otherwise gets out of your way), alongside being a single executable.

ramses0

2 days ago

Looks great, but it is clearly crying for "yaml front matter", eg: `import ...\n----\n# Content ...`, either that or `<?mdx/php ... ?>` tags... ;-)

Seriously, love this simplification of content, and taking care of all the hairy details around `<CustomComponent>...</...>`. It's what the web should have been all along!

james_marks

2 days ago

There's a lot of ways to convert MD to HTML, but fewer tools to collaborate with non-devs to edit and maintain those markdown files.

I've been considering Spinal[0] (no association) to bridge that gap, any others I should be looking at?

[0] https://spinalcms.com

sholladay

2 days ago

I highly recommend Astro and Starlight for building websites from Markdown. It is very simple to set up and can grow with you as your needs become more complex.

https://starlight.astro.build/

Saris

2 days ago

The example page has very light colored text on a light background, almost impossible to read!

oxalorg

2 days ago

Sorry but this is anything but simple to me.

I consider my own static site generator [1] much simpler than this. Around 250 SLOC with 4 dependencies (markdown2, pyyaml, jinja2, Pygments)

[1]: https://github.com/oxalorg/genox

oneshtein

2 days ago

I use one line static site generator:

  for I in *.md; do pandoc "$I" --template=template.html --metadata title="My Site" -o "${I%.md}.html"; done

masfuerte

2 days ago

pandoc is awesome. As well as standard markdown it can handle syntax highlighting, convert LaTeX equations to MathML and much else besides.

0xbadcafebee

2 days ago

Came here to post this too. Pandoc and a few lines of shell, all you need. Here is a super fancy Makefile:

  CONTENT_DIR  := content
  BUILD_DIR    := public
  MD_FILES := $(shell find $(CONTENT_DIR) -name '*.md')
  HTML_OUT := $(patsubst $(CONTENT_DIR)/%.md,$(BUILD_DIR)/%.html,$(MD_FILES))
  .PHONY: all clean assets serve
  
  all: $(HTML_OUT) assets
  assets:
   @mkdir -p $(BUILD_DIR) && cp -a static/style.css $(BUILD_DIR)/
  $(BUILD_DIR)/%.html: $(CONTENT_DIR)/%.md templates/default.html site.yaml
   @mkdir -p $(dir $@)
   pandoc --standalone --from gfm --to html5 \
     --template=templates/default.html \
     --metadata-file=site.yaml \
     --toc --toc-depth=3 \
     -o $@ $<
Ask ChatGPT, it'll spit out the rest (sample posts, template, CSS, YAML, Makefile, etc)

dtedesco1

6 days ago

I wanted a dumb & simple way to make a modern website with text files, so I made one. Small, static-first Next.js boilerplate, intentionally minimal, just markdown → website, with optional React components when you want them.

Just updated it; what’s new:

• Next.js 15.5.2 + React 19.1.1 • Better typing for error boundaries (React 19) • Robust handling for Next 15 async params • Updated DaisyUI, MDX, and tooling

Use it for docs, personal sites, landing pages, or simple content sites that still want modern Next.js ergonomics.

handzhiev

2 days ago

Hit the back button as soon as I saw nextjs

ZeroClickOk

2 days ago

Or just use Obsidian + Obsidian Publish,

You are welcome.

pityJuke

2 days ago

One of the first things I would do to evaluate a solution like this is to look at a demo. The demo looks... utterly broken to me? [0]

[0]: https://imgur.com/a/ysgJbCp

nashashmi

2 days ago

Markdown should be baked in to browsers as native now.

prmoustache

2 days ago

Well since markdown has been designed to be relatively comfortable to read in its source form, I initially thought this link would be an opinion piece on serving raw markdown pages using the browser ability to show text files as is.

lelanthran

2 days ago

> Markdown should be baked in to browsers as native now.

That is not hard to do, if you're okay with adding a script tag in your header.

nashashmi

2 days ago

Yeah but then the script tag will show up in markdown viewers.

lelanthran

2 days ago

I meant add a `<script src=...>` to the `<head>` section of the page.

Not perfect, to be sure, but it lets you create a custom element `<mark-down src=...>` that lets the page author sprinkle markdown everywhere in their page.

Fade_Dance

6 days ago

I have a fairly old mental bookmark for this purpose: blot.im. Wondering if it still holds up, or perhaps newer entrants can do the same but more elegantly.

Seems like markdown is back in vogue. The more the merrier as far as I'm concerned.

raphinou

2 days ago

If you prefer to generate a static site, take a look at https://soupault.app/ It generates a static website from markdown or other formats. Mentioning it here because it deserves more attention than it currently gets.