将许多小HTML页面与导航连接起来,用于交互。
Stitch together lots of little HTML pages with navigations for interactions

原始链接: https://blog.jim-nielsen.com/2026/small-html-pages/

作者提倡使用“大量小HTML页面”的方法来构建网站,优先考虑简单性和广泛的兼容性,而非复杂的JavaScript交互。系统不使用展开菜单等动态元素,而是利用多页面导航并辅以CSS视图过渡。 本质上,交互被处理为标准链接到新页面。例如,菜单不是通过JavaScript显示,而是导航*到*一个专门的页面。少量JavaScript被策略性地使用——具体来说,是为了在“关闭”菜单时启用“返回”功能,防止不必要地记录历史记录。 这种方法确保了即使在禁用JavaScript或使用旧版浏览器时也能正常工作,依赖于基本的跟随链接的能力。作者发现这种方法出奇地有效,迫使人们专注于核心导航原则,并最终构建出更快、更健壮、更直观的网站。它将网站构建重新定义为文档导航,而不是代码执行。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 将许多小HTML页面与交互式导航拼接在一起 (jim-nielsen.com) OuterVale 发表于 1小时前 | 隐藏 | 过去 | 收藏 | 2条评论 帮助 cluckindan 发表于 22分钟前 | 下一个 [–] 这很接近过去的做法,在服务器端包含之前。回复 jazzypants 发表于 18分钟前 | 上一个 [–] 我真的不明白这种做法的吸引力,用JavaScript构建一个漂亮的网站不是更容易吗?Google搜索没有JavaScript无法工作。说真的,有什么意义?不要只是反射性地反对我。尝试用文字表达为什么这是一个好主意。动用你的词汇并不难。回复 考虑申请YC 2026年夏季项目!申请截止至5月4日 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系方式 搜索:
相关文章

原文

I wrote about building websites with LLMs — (L)ots of (L)ittle ht(M)l page(s) — and I think it’s time for a post-mortem on that approach:

I like it.

I’ve tweaked a few things from that original post but the underlying idea is still the same, which I would describe as:

Avoid in-page interactions that require JavaScript in favor of multi-page navigations that rely on HTML and are enhanced with CSS view transitions (and a dash of JS if/where prudent).

As an example, on my blog I have a “Menu”. It doesn’t “expand” or “slide out” or “pop in” or whatever else you can do with JS. Instead, it navigates to an entirely-new page that is focused on just the menu options of my site.

I say “navigates” because it’s just a link — <a href="/menu/"> — and it functions like a link, but the navigation interaction is enhanced by CSS view transitions.

Have a newer device with a modern browser? Great, you get a nicer effect.

Have an older device, or an older browser, or JS disabled, Et al.? It’ll still work.

If you can follow a link — which is the most fundamental thing a browser can do — it will work.

So how’s it all work under the hood? In essence, all the pages have a link to the menu (except the menu page). When you navigate to the menu, that link is changed to an “X” which “closes” the menu. The closing is still just a link (back to /) but it’s enhanced with JS to actually do a “back” in the browser history. This makes it so “opening/closing” the menu doesn’t add an entry to your browser history.

Screenshot of three mobile screenshots of blog.jim-nielsen.com with highlighted sections indicating where navigational clicks can happen and how they link between eachother.

As a simplified example, the code looks like this:


<nav>
  <a href="/menu/">
    <svg>...</svg>
  </a>
</nav>


<nav>
  <a href="/" onclick="document.referrer ? history.back() : window.location.href = '/'; return false;">
    <svg>...</svg>
  </a>
</nav>

The document.referrer checks whether we came to this page as a navigation (mostly likely from within the blog itself) or via a direct visit (i.e. somebody typed it into the URL bar, unlikely but possible) which is how I suss out whether there’s a meaningful history.back() run or not.

Here’s a video of how it all works, if that’s your thing:

While this solution seems simplistic, it was not a simple thing to arrive at. It required me to spend time thinking about what was essential to navigation, how that interaction could work across multiple pages, and how I could ensure page size stayed small so the interaction was both fast and robust while remaining intuitive to use.

In other words, the approach shaped the design.

Turns out, if you have a website and you think of the browser as a way to navigate documents — rather than a runtime to execute arbitrary code and fetch, compile, and present them — things can be a lot simpler than our tools often prime us to make them.

联系我们 contact @ memedata.com