leafwiki icon indicating copy to clipboard operation
leafwiki copied to clipboard

Feature-Request: Server-rendered Markdown on page routes (SEO-friendly, not full SPA SSR)

Open jochumdev opened this issue 4 months ago • 18 comments

Related to #67, scoped to page rendering only. Right now GET /some/page returns the SPA shell <div id="root"></div>, and content loads via a JS fetch to the API afterward. That works well for browsers, but leaves search crawlers, link previews, LLM agents, and curl looking at an empty page.

Proposal: have the existing page route render the page's Markdown to HTML server-side and include it directly in the response body, alongside the current shell. The SPA boots and takes over exactly as it does today. Along with it:

  • sitemap.xml generated from tree.json
  • per-page / <meta name="description"> in the initial HTML</li> <li>robots.txt check for page paths</li> <li>canonical URL + OpenGraph tags</li> </ul> <p>I'm happy to implement that.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Jul 09 '26 02:07 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> <div class="clear-both"></div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Hi @jochumdev,</p> <p>Thanks for your request. I haven’t implemented it yet because I didn’t want to maintain two separate templates.</p> <p>A page-specific title should already be included. At least Google is able to crawl the page, but I agree that this is not optimal from an SEO perspective.</p> <p>For agents and LLM workflows, an API should also be available later on.</p> <p>Could you provide me with a plan outlining how you would approach your points?</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/6125824?v=4" alt="perber avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Jul 10 '26 09:07 </span> <a class="owner-name" href="http://gitmemories.com/perber"> perber </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>I'm in the process of releasing the v1.0 of a project of mine.</p> <p>The biggest thing was/is render the Markdown as HTML into each <code>GET</code> so when you curl <code>https://docs.incus-compose.org/home</code> for example you get the full Markdown as HTML. It must NOT be pixel perfect or perfect in any sense as React will replace the div.</p> <p>That would mean, human as in JavaScript viewers would see the renderered react page while Bots see the HTML. I thought about <code><noscript></code> for that, but Claude told me that noscript and Search Engines are no friends cause of abuse in the past.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Jul 10 '26 10:07 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Maybe hidden content? A full hydration would be too much work and maintenance.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/6125824?v=4" alt="perber avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Jul 10 '26 14:07 </span> <a class="owner-name" href="http://gitmemories.com/perber"> perber </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>No, just the skeleton of the html generated by goldmark, no need for any css or other eye things as that gets fully replaced by React.</p> <p>EDIT: Hidden content gives us again SEO troubles I'm sure.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Jul 10 '26 15:07 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>I added the new sitemap.xml to google search console and my site https://docs.incus-compose.org vanished from google on keywords it was 2nd before ("incus compose" and "incus-compose").</p> <p>I found that google is not happy with "/" being redirected to "/home" via JavaScript, so I fixed that.</p> <p>Another issue I'm investigating is the flickering that still is here cause I thought google dislikes my page cause of hidden text, after it works without the redirect I'll test again with hidden fonts.</p> <p>ETA: Around 2-3 Weeks cause I have to wait on google to re-index on each change.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 02 '26 01:08 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>An LLM told me to use this as the cleanest non-intrusive fix for the flickering:</p> <pre><code class="language-css">#app-root { opacity: 0; transition: opacity 120ms ease; } #app-root.mounted { opacity: 1; } </code></pre> <pre><code class="language-js">// after React's initial render callback / useEffect on app mount document.getElementById('app-root').classList.add('mounted'); </code></pre> <p>@perber what do you think about this? You have more experience with React than I do.</p> <p>Kind regards, René</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 04 '26 08:08 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Thanks @jochumdev,</p> <p>looks good. Lets give it a try.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/6125824?v=4" alt="perber avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 05 '26 10:08 </span> <a class="owner-name" href="http://gitmemories.com/perber"> perber </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>The page is back on Google (Rank #2 for my keywords :) )</p> <p>I'll now try to get rid of the flickering and wait a week or two to see if it vanishes. 👎</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 05 '26 21:08 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>I implemented this today, will see if my site vanishes in the next 2 weeks.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 11 '26 10:08 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Congrats! To be on #2! Thanks @jochumdev for keeping me updated!</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/6125824?v=4" alt="perber avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 11 '26 10:08 </span> <a class="owner-name" href="http://gitmemories.com/perber"> perber </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Dang I did that change yesterday evening ... Google already delisted it.</p> <p>DuckDuck Go rank 1</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 11 '26 10:08 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Nice, at least DuckDuckGo :)</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/6125824?v=4" alt="perber avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 11 '26 11:08 </span> <a class="owner-name" href="http://gitmemories.com/perber"> perber </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Did remove the font trickery just now, will see if it comes back on google with flickering.</p> <p>Thanks for the nice phone call :)</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 11 '26 11:08 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>What if we make flickering opt-in ? (<strong>lol</strong> laughing about my own sentence).</p> <p>We could add an option like <code>LEAFWIKI_ENABLE_FLICKER</code> to enable static rendering of HTML, Header stuff I do in the same branch can stay with and without the flicker option.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 14 '26 20:08 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>I would like to see static rendered sections/pages that would make many usecases so much simpler</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/4124273?u=76f36d67582393d66ee0732c4e26c4b5f3525dc9&v=4" alt="tarumes avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 17 '26 21:08 </span> <a class="owner-name" href="http://gitmemories.com/tarumes"> tarumes </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>I found some frameworks which maybe it could work for this use case. I will play around with it a bit and keep you posted.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/6125824?v=4" alt="perber avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Aug 22 '26 16:08 </span> <a class="owner-name" href="http://gitmemories.com/perber"> perber </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Shipped in <a href="https://github.com/perber/leafwiki/releases/tag/v0.15.0" rel="nofollow" target="_blank" >v0.15.0</a>: public wikis serve the rendered page to search-engine crawlers, page meta tags, robots.txt/sitemap.xml with <code>--public-url</code>, Markdown via <code>Accept: text/markdown</code>, and <code>?ssr</code> to preview the crawler view (#1757, #1759, #1785, #1786, #1789, #1791, #1793, #1796, #1827). Closing; please open a new issue for anything missing.</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/6125824?v=4" alt="perber avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Nov 22 '26 18:11 </span> <a class="owner-name" href="http://gitmemories.com/perber"> perber </a> </div> </div> <div class="clear-both"></div> </div> <div class="issue-body"> <p> <p>Many thanks!</p> </p> <div class="body-meta"> <div class="owner-info float-right"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <span class="w3-opacity w3-small"> Nov 22 '26 22:11 </span> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> </div> <div class="clear-both"></div> </div> </section> </div> </div> </div> <aside class="detail-info-box"> <h3 class="title pkg-infobox-metadata">Labels</h3> <div class="pub-labels"> <div class="pub-label-item" style="background-color: a2eeef"> enhancement </div> </div> <script type="text/javascript"> atOptions = { 'key' : '6ca19c2b16e3f20a28885886ef99a68e', 'format' : 'iframe', 'height' : 250, 'width' : 300, 'params' : {} }; </script> <script type="text/javascript" src="https://www.highperformanceformat.com/6ca19c2b16e3f20a28885886ef99a68e/invoke.js" ></script> <h3 class="title">Owner</h3> <div class="owner-info flex-items-center d-flex"> <img class="owner-avatar" src="https://avatars.githubusercontent.com/u/358074?v=4" alt="jochumdev avatar" width="48" height="48" title="Published by a pub.dev verified publisher"/> <a class="owner-name" href="http://gitmemories.com/jochumdev"> jochumdev </a> </div> <hr class="color1"> <h3>Other Repo Issues</h3> <div class="packages"> </div> <div style="clear: both"></div> </aside> </div> </div> </main> <footer class="site-footer"> <span>© 2022 Git Memory </span> <a class="link sep" href="http://gitmemories.com/privacy-policy">Policy</a> <a class="link sep" href="http://gitmemories.com/terms">Terms </a> <a class="link sep" href="http://gitmemories.com/contact">Contact </a> <a class="link sep" href="https://exchangetuts.com">Exchangetuts </a> <a class="link sep" href="https://onltools.com/">Onltools </a> <a class="link sep" href="https://serveraide.com/">Serveraide </a> </footer> <script src="http://gitmemories.com/js/app.js?id=a1337f444c840fae34ad"></script> </body> </html>