{"id":13669842,"url":"https://github.com/mkaz/lanyon","last_synced_at":"2025-04-06T02:10:23.202Z","repository":{"id":16358881,"uuid":"19108933","full_name":"mkaz/lanyon","owner":"mkaz","description":"markdown web server","archived":false,"fork":false,"pushed_at":"2017-10-25T12:48:14.000Z","size":14458,"stargazers_count":509,"open_issues_count":5,"forks_count":30,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-30T01:11:11.111Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CSS","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/mkaz.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":"2014-04-24T13:14:17.000Z","updated_at":"2024-11-24T17:47:56.000Z","dependencies_parsed_at":"2022-09-10T17:50:14.956Z","dependency_job_id":null,"html_url":"https://github.com/mkaz/lanyon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkaz%2Flanyon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkaz%2Flanyon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkaz%2Flanyon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mkaz%2Flanyon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mkaz","download_url":"https://codeload.github.com/mkaz/lanyon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423515,"owners_count":20936626,"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":[],"created_at":"2024-08-02T09:00:23.433Z","updated_at":"2025-04-06T02:10:23.166Z","avatar_url":"https://github.com/mkaz.png","language":"CSS","readme":"\n# Lanyon, a markdown web server\n\nLanyon is a simple web server, which reads directories of markdown files and\nconverts them to HTML and serves. An intuitive and easy way to create a website.\n\nLanyon was derived from my static site generator,\n[Hastie](https://github.com/mkaz/hastie). I grew tired of the multiple steps for\ncreating, generating and publishing. Plus, using a static site generator has a\nduplicate source tree and generated tree, with some assets in each. Lanyon\nsimplifies this with one set of directories with content and assets.\n\n---\n\n## Getting Started\n\n#### Install\n\nBinaries are available in the `binaries` folder for Mac OS X and Linux (amd64).\nYou can also build a binary from the available Go source code.\n\nThe only dependency for building is the `github.com/russross/blackfriday`\nlibrary for markdown parsing. So to build yourself, assuming you have [Golang\ninstalled](http://golang.org/doc/install):\n\n```bash\n$ git clone https://github.com/mkaz/lanyon\n$ cd lanyon\n$ go get\n$ go build\n```\n\nOnce you have the binary built or downloaded, copy it to a directory within your\npath, `~/bin/` or `/usr/local/bin/` are two great spots.\n\n\n#### Run Site\n\nA quick way to see what's going on is to check out the example site. You can run\nthe example site by running the binary from that directory. Lanyon looks for the\nconfig file `lanyon.json` in the directory it was started in. The config file\ntells it where to look for templates and what directory to serve content from.\n\n```bash\n$ cd lanyon/example\n$ lanyon\n\u003e\u003e\u003e Lanyon listening on http://localhost:9999\n```\n\nYou can now go to that URL and see the demo site running. All markdown files,\nfiles with the extension `.md` are reference on the web server with .html\nextension.\n\nFor example a call to `/giraffe.html` will first check to see if the html file\nexists, if so it will serve the file. Otherwise it will check if `giraffe.md`\nexists and convert that to HTML.\n\n---\n\n## Configuration\n\nThe configuration file is in JSON format, here is an example with all parameters\nset:\n\n```json\n{\n    \"PortNum\": 9999,\n    \"TemplateDir\": \"templates\",\n    \"PublicDir\": \"public\",\n    \"RedirectDomain\": [\"www.mkaz.com\", \"www.mkaz.com\"]\n}\n```\n\n**PortNum** - [required] the port number for the web server to listen to, if you\nset to port 80 it will require being started by root user who has permission\n\n**TemplateDir** - [required] the directory which holds the template files,\naccepts a full path, or relative to lanyon start directory. Directories can\ninclude the trailing slash.\n\n**PublicDir** - [required] the directory which holds the main site's markdown\nfiles. This is your web server root, all assets are also included in here.\nAccepts a full path, or relative to lanyon start directory.\n\n**RedirectDomain** - [optional] A tuple of domains which if specified, checks to\nsee if the requested domain matches the first, if the domain does not match,\nissues a redirect to the second domain.\n\nIt would be common to include the same domain in both, to make sure all requests\ngo to the proper domain. In my production config, I use this parameter to redirect\nall requests through the CDN, unless it is an origin request, so it looks like\n[\"origin.mkaz.com\", \"www.mkaz.com\"]\n\n\n---\n\n## Templates \u0026 Customizing\n\nBy far the easiest way to customize is to modify the style.css file to fit your\nneeds. The example templates produce a common blog markup, based off the open\nsource [WordPress Underscores theme](https://github.com/automattic/_s).\n\nFor deeper customization, Lanyon uses Go Templates which is a relatively simply\ntemplating language providing basic variable substitution and minimal logic. You\ncan modify the templates to fit your needs. See the full documentation at\nhttp://golang.org/pkg/text/template/\n\nGet started customizing by looking at the example templates in the repository.\nExamples exist for post and category templates. You can add your own template by\nnaming the file \"custom.html\" where \"custom\" is the name of your template.\n\nYou would refer to this template in the front matter of your page\n\n        ---\n        title: My Page Title\n        date: 2005-02-01\n        layout: custom\n        ---\n\n        My page content\n\n\nVariables available to the template:\n\n    .Title - title of page\n    .Content - main body content of page\n    .Category - directory file resides\n    .Layout - template used for layout\n    .Params - a map of key-value params\n\n\nLanyon will create a parameter out of any front matter variables it does not\nrecognize. This becomes a flexible way to control templates and customize\nspecific pages. Here's an example, using a parameter to include jQuery.\n\nIn the page you want to include jQuery, include the following front matter\n\n    ---\n    title: My jQuery Page\n    jquery: yes\n    ---\n\n    This is a page that will include jQuery\n\nAnd then within your template, you can use an if-else clause to check for the\njQuery Parameter and include.\n\n    {{ if .Params.jquery }}\n        \u003cscript src=\"/a/jquery.min.js\"\u003e\u003c/script\u003e\n    {{ end }}\n\nNote: Only the templates can use the templating language, variables and logic\nare not available within the individual markdown pages.\n\n---\n\n## Error Page\n\nWhen a page is not found, Lanyon looks for a file called `404.md` to serve as\nthe error page. If this page does not exist it will serve a plain error message.\n\n---\n\n## Less Support\n\nLanyon supports automatic compilation of Less files into CSS. This requires\n`lessc` to be installed and then any files created with `.less` extension within\nthe public directory will automatically be compiled to css. You should access\nthem as `.css`.\n\nFor example, the file `public/a/style.less` would be accessed through the web\nserver as `http://localhost:9999/a/style.css`\n\nYou can install `lessc` using the node.js package manager, npm. If you already\nhave node installed:\n\n```bash\n$ npm install -g less less-plugin-clean-css\n```\n\nSee [lesscss.org](http://lesscss.org/) for more information.\n\n\n---\n\n## Performance\n\nI think Lanyon will perform quite well on most servers. However, I recommend\nsetting up a reverse-proxy caching server such as\n[Varnish](https://www.varnish-cache.org/) or [nginx](http://nginx.org/) in\nfront.  Additionally, you can use a CDN service such as [Amazon\nCloudFront](http://aws.amazon.com/cloudfront/) to further improve serving\nperformance and offload load.\n\nI use Lanyon to serve my personal site [mkaz.com](http://mkaz.com) without a\nproxy cache, but with Amazon CloudFront as a CDN.\n\n---\n\n## About\n\nLanyon is licensed under MIT Open Source license, see LICENSE file for details.\n\nI welcome any comments, suggestions, contributions or just well wishes. Using\ngithub is probably easiest but if you want, you can email me at marcus@mkaz.com\nor reach me on Twitter at [@mkaz](https://twitter.com/mkaz).\n\n","funding_links":[],"categories":["CSS"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkaz%2Flanyon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmkaz%2Flanyon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmkaz%2Flanyon/lists"}