Dil Green
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Static site generation from HackMD content ## Intent A 'static site generator' (SSG) is a tool which takes a number of content files and uses configuration files as the parameters for their translation into HTML to provide a complete, structured, multi-page website without dynamically created content. [Here's a fuller explainer](https://davidwalsh.name/introduction-static-site-generators). Where responsive elements are required, these are typically provided using javascript. This document explores what would be needed to generate such sites from HackMD files. ## Why is this of interest or importance? The motivation here is to outline the possibillity of producing a static 'knowledge' site from materials that are composed in HackMD. That at intervals, it might be useful to publish a 'current version' of those pages from the hackMD wiki which are considered 'stable', in a format which is not bounded by HackMD's UI / branding. The format desirable for this might be a 'simplified', 'article only' approach suitable for interested readers looking for the content, not wanting to be distracted / made nervous by editing tools (a common issue with wiki presentations). This document is about an approach to that. ## Overview - HackMD (HMD hereafter) is a powerful, web-based document creation and editing tool with usable collaboration features. - Text content is produced in markdown, but there are a number of other translation tools to give a very useful range of content types including graphs and diagrams. - HMD has a built-in html export tool (with two choices 'HTML' and 'raw HTML' - see below). - HMD has fairly granular team and permissions capacities. - It looks as if HMD has a [API interface, but from the GitHub](https://github.com/hackmdio/api-client), it is hard to find out much. - Likewise, there appears to be a [HackMD command line tool](https://github.com/hackmdio/hackmd-cli) which is more fully documented. - HMD has a simple wiki-like link / new page building capability. These features would seem to form the basis for a workable proposition to build a static. There is a repo on the [HMD github](https://github.com/hackmdio) that promises to do something aloing these lines - [How to make a doc site on GitHub with HackMD](https://github.com/hackmdio/docs-with-hackmd)- last commit 2 years ago. This uses a popular SSG tool called [Jekyll](https://programminghistorian.org/en/lessons/building-static-sites-with-jekyll-github-pages) and HMD's built-in [sync to gitHub tool](https://hackmd.io/c/tutorials/%2Fs%2Flink-with-github). There is another repo that looks as if it is simply about allowing for custom Jekyll themes - although the readMe is not very helpful - [A GitHub Action for Custom Jekyll Builds on GitHub Pages](https://github.com/hackmdio/jekyll-deploy-gh-pages) - last commit 2 years ago. The lack of recent activity does not imbue confidence, but this may be good enough to begin with. However, HMD is simply used as a markdown editor, losing both rich content types and internal wiki links. ## Typical static site generation process - content files are created - typically using markdown. - these include 'front matter' - meta-data, typically written in a YAML or TOML code block, which provides information used during the site building process. Different site generators provide different levels of sophistication. - configuration files are created - typically using YAML or TOML - these contain several kinds of information - base url and other site defining characteristics - content structuring information, if any. This might specify the existence of 'post' and 'page' type content, as with a typical blog, but any desired categorisation is possible - HTML templates relating to page types. For a blog site, there might be 'index', 'post' and 'page' templates. There is also typically at least one 'list' type template (NB: for a static site, dynamic 'search' tools are not possible. Instead, SSGs pre-compile pages for searches of known kinds - categories, tags, content types. live sorting of such lists is also not possible, so if different sortings are required, these also need to be pre-specified). - The above provides the minimum necessary material, but for more sophistication, additional files are often provided - 'partial' templates to support site-wide features like headers, navigation, footers etc - javascript inclusions in templates (potentially in content, although this is not normally a feature) - CSS files - Editable 'theme' collections of templates and configuration files - A 'build' tool is applied to the collection of files - typically stored in a Git repo. a single invocation of such a tool might provide both site building and deployment , or several tools might be needed. - either through a command-line - or through a git-platform 'pipeline' process - Sites are either self-hosted or deployed to a cloud-server. [Netlify and others](https://www.hostingadvice.com/how-to/best-static-web-hosting/) provide free hosting for static sites with even fairly large bandwidth usage. ## How might the above be achieved using HackMD? ### Overview Clearly, since HMD already provides for sophisticated HTML production, 'understanding' a variety of markup tools to provide a variety of content types, the workflow with HMD would differ a little from that described above. In an HMD context an SSG tool would most usefully take HMD-produced HTML files as its input files, rather than raw markdown text files. - config and template files, presumably created in HMD, would be fairly straightforward. - site-wide material like header, footers, navigation would need to be inserted. - Handily, HMD's 'raw HTML' export option produces a 'content only' HTML markup as a single `<div>` with `<span>` elements. - The 'complete' HTML export links to some fairly detailed stylesheets and has a table-of-contents built-in. - List pages would need to be compiled and created. - HMD's sync to Github tools would be used - 'pull' for editing existing content, 'push' for committing new content - Commits could be used to trigger an automatic site build/deploy pipeline. ### Issues - Neither HTML export option builds links to 'internal' HMD pages. An `<a>` tag *is* produced, with a null reference - so that it *is* possible to know that a link is intended. Unless the visible linked text is the title of a page, though (this is not a requirement in HMD), it would be impossible (?) to determine which file to link to. Links to HackMD pages *not* published would result in 'page missing' screens unless amended by the SSG. - Changes to HMD's html export routines could break the generation workflow/algorithms. ## Alternative approaches Theses are alternative approaches to content creation and editing that feed into SSG workflows. As such, they would not support HMD's wide range of markup translation capacities, and also will be unlikely to offer wiki link creation tools. [headless CMS](https://alternativeto.net/tag/content-as-a-service/) - these manage content in a structured way (JSON), but don't assume anything abhout a front end. [Sanity.io](https://alternativeto.net/software/sanity-io/about/) is an example that is open-source. [Prose content authoring](http://prose.io/#about)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully