{"id":15130845,"url":"https://github.com/charles-m-knox/ghost-to-hugo","last_synced_at":"2025-04-05T20:12:37.386Z","repository":{"id":257798164,"uuid":"854353108","full_name":"charles-m-knox/ghost-to-hugo","owner":"charles-m-knox","description":"Takes Ghost blog posts and converts them to Hugo-compatible markdown files.","archived":false,"fork":false,"pushed_at":"2024-09-24T03:01:06.000Z","size":42,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-18T19:30:30.898Z","etag":null,"topics":["ghost","ghost-blog","go","golang","hugo","markdown","sql","synchronize","synchronizer"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charles-m-knox.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-09T02:35:28.000Z","updated_at":"2024-09-24T03:01:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"345b87a6-e603-46ea-8d9e-1591689a13dc","html_url":"https://github.com/charles-m-knox/ghost-to-hugo","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"2d052267a4daa42b3f24bfb08c02a3e9abc577a4"},"previous_names":["charles-m-knox/ghost-to-hugo"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-m-knox%2Fghost-to-hugo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-m-knox%2Fghost-to-hugo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-m-knox%2Fghost-to-hugo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charles-m-knox%2Fghost-to-hugo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charles-m-knox","download_url":"https://codeload.github.com/charles-m-knox/ghost-to-hugo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393572,"owners_count":20931813,"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":["ghost","ghost-blog","go","golang","hugo","markdown","sql","synchronize","synchronizer"],"created_at":"2024-09-26T03:07:13.037Z","updated_at":"2025-04-05T20:12:37.022Z","avatar_url":"https://github.com/charles-m-knox.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ghost-to-hugo\n\nTakes Ghost blog posts and converts them to Hugo-compatible markdown files.\n\nThis leverages a database connection - Ghost recommends mysql as its supported database type, but it can technically work with any compliant driver that implements Go's `database/sql` interfaces.\n\nThis is compatible with **Ghost v5.87.1**. Compatibility with any other version is not guaranteed.\n\n## Requirements\n\nThe only specific requirement is that your Hugo project *must* support some kind of raw HTML shortcode, such as:\n\n`themes/your-theme/layouts/shortcodes/rawhtml.html`\n\n```text\n{{ .Inner }}\n```\n\nThis is necessary because the raw HTML from Ghost has to be placed somewhere in the rendered Hugo Markdown files.\n\nIf your shortcode is called something else, you can define a custom shortcode in the config using `RawShortcodeStart` and `RawShortcodeEnd`.\n\n## Example Usage\n\nSee [`examples/simple/README.md`](./examples/simple/README.md).\n\n## Warnings\n\n**Please verify the output of this application before publishing it**. If your configuration is incorrect, it may publish premium content from your Ghost instance to the world, or it may publish newsletters as posts.\n\n## Features\n\n- Supports replacing all instances of `__GHOST_URL__` (which is what Ghost uses) with your own string, see `GhostURL` in the config\n- Parses every HTML XML node and does the following:\n  - removes all `height` and `width` values from `\u003cimg\u003e` tags, because Ghost assigns weird values for these\n  - optionally can replace specific strings found in all `\u003ca href=\"https://example.com\"\u003e` tags' `href` attributes, such as replacing `example.com` with `nojs.example.com` (see `LinkReplacements` in the config)\n- Can choose to ignore publish/draft state and publish all posts - see `PublishDrafts` in the config\n- Set `SetUnpublishedToNow` to `true` in the config to force any unpublished documents to be rendered (decrements post time by one second for each post without a publish date)\n- Can apply basic filters via post status, visiblities, and types (see `PostTypes`, `PostStatuses`, `PostVisibilities` mappings in the config)\n- Set `ForbidEmptyPosts` in the config to halt the program if any empty (null) posts are encountered\n\n## Motivation\n\nGhost is an incredible project that has empowered myself and others in my community to achieve higher productivity with digital content marketing online.\n\nHowever, Ghost is very JavaScript-heavy. In my browser, Ghost admin/blog post pages can use up to 200MB RAM per tab. I personally like to use less RAM if possible.\n\nI wanted an option to use both Ghost and statically rendered Markdown files that work with Hugo. A browser tab using a barebones Hugo theme can use between 20-30MB RAM, almost 10% of what the Ghost-equivalent uses.\n\nThe idea is to run `ghost-to-hugo` on a regular basis, such as once per day or hour, and then serve the Hugo-rendered content from e.g. `https://nojs.example.com`, whilst simultaneously serving your Ghost-powered content at `https://example.com`.\n\n## Structure\n\nIn order to keep dependencies to zero (see [`go.mod`](./go.mod) - it only uses the standard library), this Go module is structured as a library that can be imported by any application.\n\nThis has the benefit of not requiring any specific SQL driver - it accepts SQL rows themselves from the `database/sql` package. You can use any compliant driver, such as sqlite or postgres - although I haven't tried anything aside from mysql, so tread carefully.\n\n## Other notes\n\nThere may be other hidden capabilities in this that I've not documented or explored fully. For example, it *may* be possible to get creative with templates to support rendering the featured image for a post (the default template does not support this currently).\n\n`.json` files are used for configuration because I do not want to pull in larger dependencies like `yaml`.\n\n## Development notes\n\nThe `ghosttohugo` package is the primary library for this module. Its unit test coverage is currently at **`70.7%`** and at this time, I do not intend to get it higher. The core business logic is well-tested; everything else remaining is not worth unit testing.\n\n## Compatibility\n\nHere is a list of all tested Ghost versions that are known to work:\n\n- v5.87.1\n\nThe only table that needs to be read from the database is the `posts` table. If any database migrations occur upstream, this application will likely break.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharles-m-knox%2Fghost-to-hugo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharles-m-knox%2Fghost-to-hugo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharles-m-knox%2Fghost-to-hugo/lists"}