Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rarst/wprss2hugo
WordPress eXtended RSS to Hugo importer.
https://github.com/rarst/wprss2hugo
hugo importer wordpress
Last synced: 3 months ago
JSON representation
WordPress eXtended RSS to Hugo importer.
- Host: GitHub
- URL: https://github.com/rarst/wprss2hugo
- Owner: Rarst
- License: mit
- Created: 2019-10-18T13:18:12.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-05-25T14:20:49.000Z (over 2 years ago)
- Last Synced: 2024-03-26T03:24:11.586Z (10 months ago)
- Topics: hugo, importer, wordpress
- Language: PHP
- Homepage:
- Size: 22.5 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# wprss2hugo — WordPress to Hugo importer
_Go static. Hugo static._[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Rarst/wprss2hugo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Rarst/wprss2hugo/?branch=master)
[![Latest Stable Version](https://img.shields.io/packagist/v/rarst/wprss2hugo.svg?label=version)](https://packagist.org/packages/rarst/wprss2hugo)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/rarst/wprss2hugo.svg)](https://packagist.org/packages/rarst/wprss2hugo)
[![PDS Skeleton](https://img.shields.io/badge/pds-skeleton-blue.svg)](https://github.com/php-pds/skeleton)wprss2hugo is an importer from the [WordPress](https://wordpress.org/) eXtended RSS export file format to the [Hugo](https://gohugo.io/) static site generator.
It aims to be comprehensive and reasonably flexible, but mostly to lower my hosting bill.
## Install
wprss2hugo is a command line PHP 7.3+ project and installs with [Composer](https://getcomposer.org/):
```bash
composer create-project rarst/wprss2hugo
```## Use
```bash
cd wprss2hugo
php bin/wprss2hugo.php example.WordPress.YYYY-MM-DD.xml
```Results are generated in the `output` folder.
_Note:_ WordPress might not store and export valid HTML paragraphs markup. You might want to add something like `add_filter( 'the_content_export', 'wpautop' );` to the WP installation before export.
### Command line arguments
```bash
php bin/wprss2hugo.php --helpArguments:
file Path to a WordPress export XML file.
Options:
--content-type= html|md [default: "html"]
--front-matter-type= yaml|toml|json [default: "yaml"]
--data-type= yaml|toml|json [default: "yaml"]
```_Note:_ conversion to Markdown for the post content is best effort and might be suboptimal on complex markup.
_Note:_ TOML format is not meant for data, data files in TOML will have the data assigned to a dummy `data` root key.
## Data map
Source | Destination
-|-
site title, URL, description | `config.[data type]`
posts, pages, attachments, custom post types | `content/[post type]/[slug].[content type]`
tags, categories, formats, terms | `content/[taxonomy]/[term]/_index.[content type]`
authors | `content/authors/[login]/_index.[content type]` (taxonomy)
comments | `data/comments/[post ID].[data type]`## Data retrieval
### Attachments
Attachments are stored as `attachment` page type and can be retrieved by a parent post ID:
```go
{{ $attachments := where (where .Site.Pages "Type" "attachment") "Params.parentid" .Params.id }}{{ with $attachments }}
Attachments
{{ range . }}
{{ end }}
{{ end }}
```### Comments
Comments are stored as data files and can be retrieved by a parent post ID:
```go
{{ with .Site.Data.comments }}
{{ with index . (string $.Page.Params.id) }}
Comments
- {{ .author }} says: {{ .content | safeHTML }}
{{ range sort . "id" }}
{{ end }}
{{ end }}
{{ end }}
```