{"id":19728840,"url":"https://github.com/swharden/md2html-php","last_synced_at":"2025-04-30T01:31:29.654Z","repository":{"id":49782969,"uuid":"251185781","full_name":"swharden/md2html-php","owner":"swharden","description":"A flat-file dynamic markdown-to-HTML site generator using PHP","archived":false,"fork":false,"pushed_at":"2021-06-10T03:44:39.000Z","size":12729,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-29T17:16:34.887Z","etag":null,"topics":["convert","converter","markdown","php","static-site","static-site-generator"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swharden.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-30T02:54:09.000Z","updated_at":"2024-03-15T17:04:25.000Z","dependencies_parsed_at":"2022-08-28T05:02:54.462Z","dependency_job_id":null,"html_url":"https://github.com/swharden/md2html-php","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2Fmd2html-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2Fmd2html-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2Fmd2html-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swharden%2Fmd2html-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swharden","download_url":"https://codeload.github.com/swharden/md2html-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224193127,"owners_count":17271238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convert","converter","markdown","php","static-site","static-site-generator"],"created_at":"2024-11-12T00:08:05.387Z","updated_at":"2024-11-12T00:08:05.926Z","avatar_url":"https://github.com/swharden.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Markdown Site with PHP\n\n**This project is a flat-file website that dynamically serves Markdown files using PHP.** There are many options for managing website content, but I prefer this method for my personal websites because:\n* **No build step:** unlike static site generators, HTML is generated dynamically from markdown files when pages are requested, so there is no need for a build step.\n* **No database:** This is a flat-file site, so no database is required to store content.\n* **Easy Installation:** Use git to clone this repo\n* **Easy Backup:** Just zip the web folder\n* **Easy Authoring:** Just create a folder with `index.md`\n* **Clean URLs:** Page URLs are folder paths\n\n### Features\n* Automatic anchor links for headings\n* Syntax highlighting in code blocks\n* Add a table of contents using `![](TOC)`\n* Embed YouTube videos using `![](YouTubeURL)`\n* Template files are HTML and easy to customize\n* Markdown headings and tables are styled to resemble GitHub\n* Dynamic generation of sitemap\n* Dynamic generation of RSS feed\n* Custom functionality is easy to add\n\n### Example Websites\n* https://swharden.com\n* https://swharden.com/pyabf\n* https://swharden.com/CsharpDataVis\n* https://swharden.com/software/LJPcalc\n\n## Developer Notes\n\n### Installation\n\n**Step 1:** Use `git` to clone this repo _outside_ your web folder. I suggest `/var/www/md2html`\n\n**Step 2:** Link the resources folder to a web-accessible URL\n\n```\nln -ls /var/www/md2html/resources /var/www/html/md2html-resources\n```\n\n**Step 3:** Copy the quickstart demo folder to your web folder and your site will be live!\n\n**Step 4:** To create new pages, create sub-folders with an `index.md`\n\n### Develop in Docker\n\nThis repository has a ready-to-run demo site. \n\nRun `docker-compose up -d` and go to http://localhost:8081\n\n### Markdown Header\n\nMarkdown files can have an optional header containing _front matter_ to customize what `{{mustache}}` text is replaced with in the template. Default replacements are defined in `settings.php`, and any values defined in the header override those defined in the settings file.\n\n```\n---\ntitle: this text becomes the title element in the header\ndescription: this text becomes header metadata for search engines to display\n---\n\n# My Markdown Article\n\nThe rest of the ***Markdown*** text goes here...\n```\n\n### Routing Requests\n\nThis repository uses `.htaccess` to tell Apache (with mod_rewrite) to route requests to a folder containing an `index.md` to a local PHP script to handle them. If you don't use Apache or mod_rewrite, use whatever system you do have to route directory index requests similarly.\n\n### Continuous Deployment with GitHub Actions\n\nA flat-file website can be cloned onto a webserver using `git`, then PHP can execute `git pull` to update the content. By configuring GitHub Actions to make a HTTP request that executes the PHP update script every time new commits are pushed to the repository, it is possible to keep a website continuously and automatically in sync with a GitHub repository.\n\n* Clone this repo in a folder outside the web root\n* Symbolically link `wwwroot` to a web-accessible path\n* Create a secret `API_KEY` in the GitHub project\n* Store the key in `api.key` in the root folder (chmod `400`)\n* Configure GitHub Actions to HTTP request [`deploy.php`](tools/deploy.php) when new commits are pushed, using the `API_KEY` as a bearer token (see [deploy.yml](tools/deploy.yml))\n\n## Alternative Pure-Python Static Site Generator\n\nAfter using this PHP-based system for several months I grew to enjoy it for large sites with 100s of pages, but for very small sites with just a few pages it felt cumbersome to fire-up a Docker instance just to do a little page editing.\n\nI created [Palila](https://github.com/swharden/Palila) to meet this need - a small Python script to convert index.md to index.html that can be run locally (when editing) or remotely (when deploying).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswharden%2Fmd2html-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswharden%2Fmd2html-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswharden%2Fmd2html-php/lists"}