rarst / wprss2hugo
WordPress eXtended RSS to Hugo Import
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 3
Forks: 1
Open Issues: 3
Type:project
Requires
- php: >=7.3
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- league/html-to-markdown: ^4.8
- mnapoli/silly: ^1.7
- pimple/pimple: ^3.2
- prewk/xml-string-streamer: ^0.11.0
- symfony/filesystem: ^4.3
- symfony/yaml: ^4.3
- yosymfony/toml: ^1.0
Requires (Dev)
- pds/skeleton: ^1.0
This package is auto-updated.
Last update: 2024-11-25 19:46:47 UTC
README
Go static. Hugo static.
wprss2hugo is an importer from the WordPress eXtended RSS export file format to the Hugo 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:
composer create-project rarst/wprss2hugo
Use
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
php bin/wprss2hugo.php --help Arguments: 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
Data retrieval
Attachments
Attachments are stored as attachment
page type and can be retrieved by a parent post ID:
{{ $attachments := where (where .Site.Pages "Type" "attachment") "Params.parentid" .Params.id }} {{ with $attachments }} <h2>Attachments</h2> {{ range . }} <img src="{{ .Params.attachmenturl }}" {{ with .Params.meta._wp_attachment_image_alt }}alt="{{ . }}"{{ end }} /> {{ end }} {{ end }}
Comments
Comments are stored as data files and can be retrieved by a parent post ID:
{{ with .Site.Data.comments }} {{ with index . (string $.Page.Params.id) }} <h2>Comments</h2> <ul> {{ range sort . "id" }} <li>{{ .author }} says: {{ .content | safeHTML }}</li> {{ end }} </ul> {{ end }} {{ end }}