{"id":28089154,"url":"https://github.com/thhamiltonsmith/ejs-static-converter","last_synced_at":"2025-05-13T12:54:20.273Z","repository":{"id":47953168,"uuid":"516416452","full_name":"THHamiltonSmith/ejs-static-converter","owner":"THHamiltonSmith","description":"Converts an express EJS app into a static HTML website.","archived":false,"fork":false,"pushed_at":"2024-05-23T09:09:58.000Z","size":45,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-25T01:43:45.107Z","etag":null,"topics":["ejs","express","nodejs","static-site","static-site-generator"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ejs-static-converter","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/THHamiltonSmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-21T15:01:44.000Z","updated_at":"2025-04-18T16:25:33.000Z","dependencies_parsed_at":"2024-11-16T09:31:41.114Z","dependency_job_id":"3201e473-d6dc-4bba-a2d8-b670e0e5b73c","html_url":"https://github.com/THHamiltonSmith/ejs-static-converter","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"6f531985d02e4caac80671d8e5c73a8065f659d0"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THHamiltonSmith%2Fejs-static-converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THHamiltonSmith%2Fejs-static-converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THHamiltonSmith%2Fejs-static-converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/THHamiltonSmith%2Fejs-static-converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/THHamiltonSmith","download_url":"https://codeload.github.com/THHamiltonSmith/ejs-static-converter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253948328,"owners_count":21988953,"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":["ejs","express","nodejs","static-site","static-site-generator"],"created_at":"2025-05-13T12:54:19.453Z","updated_at":"2025-05-13T12:54:20.254Z","avatar_url":"https://github.com/THHamiltonSmith.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ejs-static-converter\n\nejs-static-converter allows you to convert a node app that uses the EJS templating engine into a static HTML site, independent of any server code. This is useful for converting apps or websites that were made with Node.js and EJS for easier development but don't require any server-side code into static HTML.\n\nThe package will also render any EJS `include` functions like below into the HTML package, such as a header, navbar, etc. into the new HTML file.\n\n```js\n// Include the header HTML which contains universal tags, references and other metadata.\n\u003c%- include(\"index-header.ejs\") -%\u003e\n```\n\n## Installing the package\n`express` and `ejs` are requirements for this package to work, as the site needs to be setup using the templating engine\n\nInstall the required dependencies:\n```\nnpm install express ejs\n```\n\nInstall the ejs-static-converter package:\n```\nnpm install -g ejs-static-converter\n```\n\u003cbr\u003e\n\n## Project Structure\n\nA `/public` and `/views` folder should be created in your project's root folder to contain the .ejs views and any public files such as CSS, images, etc.\n\nWhen the convert function is run, all HTML files will be created inside a `/dist` directory in the project's root folder.\n\n## Configuration\nCreate a configuration file `pages.config.js` somwhere in your project to define the pages to be converted. Here is an example config file stores in the `src/utils` folder:\n\n```js\n// src/utils/pages.config.js\n\n// Add pages to convert here:\nmodule.exports = [\n  { template: 'index.ejs', output: 'index.html', data: { title: \"Home\" } },\n  { template: 'pages/page-2.ejs', output: 'page-2/index.html', data: { title: \"Page 2\" } },\n  { template: 'pages/page-3.ejs', output: 'page-3/index.html', data: { title: \"Page 3\" } }\n];\n```\n\n## Running the Conversion\nTo convert your EJS site to a static HTML site, run the following command in your project root:\n\n```\nejs-static-converter ./src/utils/pages.config.js\n```\n\nWhere `/src/utils/pages.config.js` is the path to your config file.\n\n## Example 'server.js' file:\nHere's an example of how to set up your server and use the ejs-static-converter:\n\n\n```js\n// src/server.js\n\n// Main dependencies\nconst express = require(\"express\");\nconst app = express();\nconst server = require(\"http\").Server(app);\n\n// Declare ejs, JSON formatting and set static files folder.\napp.set(\"view engine\", \"ejs\");\napp.set(\"json spaces\", 2);\napp.use(express.static(\"public\"));\n\n// Home\napp.get(\"/\", (req, res) =\u003e {\n    res.render(\"index\", {\n        title: \"Home\",\n    });\n});\n\n// Page 2\napp.get(\"/page-2\", (req, res) =\u003e {\n    res.render(\"pages/page-2\", {\n        title: \"Page 2\",\n    });\n});\n\n// Page 3\napp.get(\"/page-3\", (req, res) =\u003e {\n    res.render(\"pages/page-3\", {\n        title: \"Page 3\",\n    });\n});\n\n// Initialise the server on port 3000.\nserver.listen(2000);\n```\n\n## Contributing\n\nIf you wan't to make a change or improvement, open a pull request or suggest a feature/bug as an issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthhamiltonsmith%2Fejs-static-converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthhamiltonsmith%2Fejs-static-converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthhamiltonsmith%2Fejs-static-converter/lists"}