{"id":27197718,"url":"https://github.com/preaction/yancy-backend-static","last_synced_at":"2025-10-25T10:04:13.063Z","repository":{"id":45216108,"uuid":"182327549","full_name":"preaction/Yancy-Backend-Static","owner":"preaction","description":"A static site backend for the Yancy CMS","archived":false,"fork":false,"pushed_at":"2021-12-31T00:30:38.000Z","size":436,"stargazers_count":2,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-17T21:17:03.978Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preaction.png","metadata":{"files":{"readme":"README.mkdn","changelog":"CHANGES","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-19T21:25:48.000Z","updated_at":"2024-04-17T21:17:03.978Z","dependencies_parsed_at":"2022-08-29T06:51:13.643Z","dependency_job_id":null,"html_url":"https://github.com/preaction/Yancy-Backend-Static","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FYancy-Backend-Static","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FYancy-Backend-Static/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FYancy-Backend-Static/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FYancy-Backend-Static/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preaction","download_url":"https://codeload.github.com/preaction/Yancy-Backend-Static/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248106812,"owners_count":21048800,"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":"2025-04-09T20:29:26.101Z","updated_at":"2025-10-25T10:04:08.024Z","avatar_url":"https://github.com/preaction.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/preaction/Yancy-Backend-Static.svg?branch=master)](https://travis-ci.org/preaction/Yancy-Backend-Static)\n[![Coverage Status](https://coveralls.io/repos/preaction/Yancy-Backend-Static/badge.svg?branch=master)](https://coveralls.io/r/preaction/Yancy-Backend-Static?branch=master)\n\n# NAME\n\nYancy::Backend::Static - Build a Yancy site from static Markdown files\n\n# VERSION\n\nversion 0.015\n\n# SYNOPSIS\n\n    use Mojolicious::Lite;\n    plugin Yancy =\u003e {\n        backend =\u003e 'static:.',\n        read_schema =\u003e 1,\n    };\n    get '/*slug', {\n        controller =\u003e 'yancy',\n        action =\u003e 'get',\n        schema =\u003e 'pages',\n        slug =\u003e 'index', # Default to index page\n        template =\u003e 'default', # default.html.ep below\n    };\n    app-\u003estart;\n    __DATA__\n    @@ default.html.ep\n    % title $item-\u003e{title};\n    \u003c%== $item-\u003e{html} %\u003e\n\n# DESCRIPTION\n\nThis [Yancy::Backend](https://metacpan.org/pod/Yancy::Backend) allows Yancy to work with a site made up of\nMarkdown files with YAML frontmatter, like a [Statocles](https://metacpan.org/pod/Statocles) site. In other\nwords, this module works with a flat-file database made up of YAML\n\\+ Markdown files.\n\n## Schemas\n\nYou should configure the `pages` schema to have all of the fields\nthat could be in the frontmatter of your Markdown files. This is JSON Schema\nand will be validated, but if you're using the Yancy editor, make sure only\nto use [the types Yancy supports](https://metacpan.org/pod/Yancy::Help::Config#Types).\n\n## Limitations\n\nThis backend should support everything [Yancy::Backend](https://metacpan.org/pod/Yancy::Backend) supports, though\nsome list() queries may not work (please make a pull request).\n\n## Future Developments\n\nThis backend could be enhanced to provide schema for static files\n(CSS, JavaScript, etc...) and templates.\n\n# GETTING STARTED\n\nTo get started using this backend to make a simple static website, first\ncreate a file called `myapp.pl` with the following contents:\n\n    #!/usr/bin/env perl\n    use Mojolicious::Lite;\n    plugin Yancy =\u003e {\n        backend =\u003e 'static:.',\n        read_schema =\u003e 1,\n    };\n    get '/*slug', {\n        controller =\u003e 'yancy',\n        action =\u003e 'get',\n        schema =\u003e 'pages',\n        template =\u003e 'default',\n        layout =\u003e 'default',\n        slug =\u003e 'index',\n    };\n    app-\u003estart;\n    __DATA__\n    @@ default.html.ep\n    % title $item-\u003e{title};\n    \u003c%== $item-\u003e{html} %\u003e\n    @@ layouts/default.html.ep\n    \u003c!DOCTYPE html\u003e\n    \u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003e\u003c%= title %\u003e\u003c/title\u003e\n        \u003clink rel=\"stylesheet\" href=\"/yancy/bootstrap.css\"\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003cmain class=\"container\"\u003e\n            %= content\n        \u003c/main\u003e\n        \u003cscript src=\"/yancy/jquery.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/yancy/bootstrap.js\"\u003e\u003c/script\u003e\n    \u003c/body\u003e\n    \u003c/html\u003e\n\nOnce this is done, run the development webserver using `perl myapp.pl\ndaemon`:\n\n    $ perl myapp.pl daemon\n    Server available at http://127.0.0.1:3000\n\nThen open `http://127.0.0.1:3000/yancy` in your web browser to see the\n[Yancy](https://metacpan.org/pod/Yancy) editor.\n\n\u003cdiv\u003e\n    \u003cimg style=\"max-width: 100%\" src=\"https://raw.githubusercontent.com/preaction/Yancy-Backend-Static/master/eg/public/editor-1.png\"\u003e\n\u003c/div\u003e\n\nYou should first create an `index` page by clicking the \"Add Item\"\nbutton to create a new page and giving the page a `slug` of `index`.\n\n\u003cdiv\u003e\n    \u003cimg style=\"max-width: 100%\" src=\"https://raw.githubusercontent.com/preaction/Yancy-Backend-Static/master/eg/public/editor-2.png\"\u003e\n\u003c/div\u003e\n\nOnce this page is created, you can visit your new page either by\nclicking the \"eye\" icon on the left side of the table, or by navigating\nto [http://127.0.0.1:3000](http://127.0.0.1:3000).\n\n\u003cdiv\u003e\n    \u003cimg style=\"max-width: 100%\" src=\"https://raw.githubusercontent.com/preaction/Yancy-Backend-Static/master/eg/public/editor-3.png\"\u003e\n\u003c/div\u003e\n\n## Adding Images and Files\n\nTo add other files to your site (images, scripts, stylesheets, etc...),\ncreate a directory called `public` and put your file in there.  All the\nfiles in the `public` folder are available to use in your website.\n\nTo add an image using Markdown, use `![](path/to/image.jpg)`.\n\n## Customize Template and Layout\n\nThe easiest way to customize the look of the site is to edit the layout\ntemplate. Templates in Mojolicious can be in external files in\na `templates` directory, or they can be in the `myapp.pl` script below\n`__DATA__`.\n\nThe layout your site uses currently is called\n`layouts/default.html.ep`.  The two main things to put in a layout are\n`\u003c%= title %\u003e` for the page's title and `\u003c%= content %\u003e` for\nthe page's content. Otherwise, the layout can be used to add design and\nnavigation for your site.\n\n# ADVANCED FEATURES\n\n## Custom Metadata Fields\n\nYou can add additional metadata fields to your page by adding them to\nyour schema, like so:\n\n    plugin Yancy =\u003e {\n        backend =\u003e 'static:.',\n        read_schema =\u003e 1,\n        schema =\u003e {\n            pages =\u003e {\n                properties =\u003e {\n                    # Add an optional 'author' field\n                    author =\u003e { type =\u003e [ 'string', 'null' ] },\n                },\n            },\n        },\n    };\n\nThese additional fields can be used in your template through the\n`$item` hash reference (`$item-\u003e{author}`).  See\n[Yancy::Help::Config](https://metacpan.org/pod/Yancy::Help::Config) for more information about configuring a schema.\n\n## Character Encoding\n\nBy default, this backend detects the locale of your current environment\nand assumes the files you read and write should be in that encoding. If\nthis is incorrect (if, for example, you always want to read/write UTF-8\nfiles), add a `?encoding=...` to the backend string:\n\n    use Mojolicious::Lite;\n    plugin Yancy =\u003e {\n        backend =\u003e 'static:.?encoding=UTF-8',\n        read_schema =\u003e 1,\n    };\n\n# SEE ALSO\n\n[Yancy](https://metacpan.org/pod/Yancy), [Statocles](https://metacpan.org/pod/Statocles)\n\n# AUTHOR\n\nDoug Bell \u003cpreaction@cpan.org\u003e\n\n# CONTRIBUTORS\n\n- Mohammad S Anwar \u003cmohammad.anwar@yahoo.com\u003e\n- Wojtek Bażant \u0026lt;wojciech.bazant+ebi@gmail.com\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2019 by Doug Bell.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreaction%2Fyancy-backend-static","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreaction%2Fyancy-backend-static","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreaction%2Fyancy-backend-static/lists"}