Code Monkey home page Code Monkey logo

wordpress-to-hugo-exporter's Introduction

WordPress to Hugo Exporter

Hugo a static site generator written in GoLang: https://gohugo.io

This repo is based on https://github.com/benbalter/wordpress-to-jekyll-exporter

Hugo Features

One-click WordPress plugin that converts all posts, pages, taxonomies, metadata, and settings to Markdown and YAML which can be dropped into Hugo.

Features

  • Converts all posts, pages, and settings from WordPress for use in Hugo
  • Export what your users see, not what the database stores (runs post content through the_content filter prior to export, allowing third-party plugins to modify the output)
  • Converts all post_content to Markdown Extra (using Markdownify)
  • Converts all post_meta and fields within the wp_posts table to YAML front matter for parsing by Hugo.
  • Exports optionally comments as part of their posts. This features needs to be enabled manually by editing the PHP source code. See file hugo-export.php at line ~40.
  • Export private posts and drafts. They are marked as drafts as well and won't get published with Hugo.
  • Generates a config.yaml with all settings in the wp_options table
  • Outputs a single zip file with config.yaml, pages, and post folder containing .md files for each post in the proper Hugo naming convention.
  • No settings. Just a single click.

Usage with a self hosted WordPress installation

  1. Place plugin in /wp-content/plugins/ folder
  2. Make sure extension=zip.so line is uncommented in your php.ini
  3. Activate plugin in WordPress dashboard
  4. Select Export to Hugo from the Tools menu

Usage at wordpress.com or any other hoster without SSH access

If you cannot install plugins in your wordpress.com instance

(I've never tried it, because not a wp.com user)

  1. Login into the backend.
  2. Create an XML export of the whole blog and download the XML file.
  3. Setup a local WordPress instance on your machine. You need PHP, MySQL or MariaDB and Nginx or Apache or Caddy Server. Alternatively you can install a Docker Compose setup https://github.com/wodby/docker4wordpress
  4. Install this plugin by downloading a zip file of this repo and uploading to WP.
  5. Import the XML export. You should take care that the WordPress version of the export matches the WP version used for the import.
  6. In the WP backend run the Export to Hugo command. If that fails go to the command line run the CLI script with memory_limit=-1, means unlimited memory usage.
  7. Collect the ZIP via download or the CLI script presents you the current name.
  8. Remove WordPress and enjoy Hugo.

Re Docker: It should be very easy to create a Dockerfile containing everything above mentioned for a one time conversion of the XML file to the Hugo format.

If you can install plugins in your wordpress.com instance

  1. Download this repo as a zip file.
  2. Login into the backend.
  3. In the plugin section, go to Add New.
  4. Upload the zip of this repo.
  5. Activate the plugin.
  6. In the WP backend run the Export to Hugo command.
  7. Collect the ZIP via download.
  8. Copy contents of the zip to your Hugo install and enjoy Hugo.

Command-line Usage

If you're having trouble with your web server timing out before the export is complete, or if you just like terminal better, you may enjoy the command-line tool.

It works just like the plugin, but produces the zipfile at /tmp/wp-hugo.zip:

php hugo-export-cli.php

If you want to offer a folder (say a mount point to a huge drive) other than using /tmp in OS, pass it as the first argument to the script:

php hugo-export-cli.php /YOUR_PATH_TO_TMP_FOLDER/

Alternatively, if you have WP-CLI installed, you can run:

wp hugo-export > export.zip

The WP-CLI version will provide greater compatibility for alternate WordPress environments, such as when wp-content isn't in the usual location.

Now what?

The exported files fit as input for Hugo. Please proceed with Hugo's Quick start guide.

Changelog

2.0.X

Updates the markdownify library, removes lots of unused code, AFAIK. Include GPL.

Many other versions

with tiny fixes

1.6

  • Fix destination against hugo 0.27
  • Fix for working on older PHP
  • Fix memory leak in Converter.php by cut unnessesary
  • updated markdownify
  • entities fix and post image added

1.5

  • Export drafts and private posts
  • Export optionally comments
  • Various changes and fixes

1.4

  • Made license explicit
  • Removed word-wrap from YAML export to prevent breaking permalinks

1.3

  • Use fork of Markdownify rather than external API to convert content from HTML to markdown
  • Better memory utilization for larger sites, props @ghelleks

1.2

  • Commmand-line support, props @ghelleks and @scribu

1.1

  • Use WP_Filesystem for better compatability
  • 1.1.1 - Use heckyeahmarkdown to prevent PHP errors when Markdownify chokes on malformed HTML
  • 1.1.2 - clarify zip.so requirement in readme

1.0

  • Initial Release

License

The project is licensed under the GPLv3 or later

wordpress-to-hugo-exporter's People

Contributors

azwjp avatar bramp avatar guycalledseven avatar hiproz avatar hydrogen2oxygen avatar jessleenyc avatar jice-lavocat avatar kiltum avatar lanshunfang avatar marcelorodrigo avatar milosz avatar patschi avatar phrawzty avatar rippler avatar sbv-csis avatar schumacherfm avatar tech4him1 avatar technologyclassroom avatar thegroundzero avatar tobbez avatar weldpua2008 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wordpress-to-hugo-exporter's Issues

Unable to activate due to syntax error

I added this plugin and it shows up in the plugin list in my admin console:

screen shot 2015-12-21 at 9 45 37 am

When I click Activate, the following error is reported:

screen shot 2015-12-21 at 9 46 19 am

Parse error: syntax error, unexpected T_STRING in /homepages/3/d374491256/htdocs/blog/wp-content/plugins/wordpress-to-hugo-exporter/hugo-export.php on line 202

A few additional notes:

  • on Wordpress version 4.4
  • I'm using a hosting provider, so I'm not sure what version of php is installed (I only have sftp access)

If you happen to have recommended troubleshooting steps, let me know. And thank you!

Plugin creates corrupt zip

Installed the plugin on a site with Wordpress 4.6.1.

Uploaded the 14ae448 in Wordpress. Activated and exported. After awhile Chome did start the download of the site.

When trying to extract the ZIP with unzip on Linux the following error message is shown:

Archive:  ~/Downloads/hugo-export.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.

What to do after generate .zip file

Hi, am really confused about what to do after generates the .zip file, it was generated successfully. I have this directory structure:

  • 22.2

    index.md

  • appointment-booking

  • contact-form

  • frontpage

  • post

  • wp-content

  • config.yaml

What should I do then? I ran hugo but it says that content folder not found, so I changed the name of wp-content to content.
Also I ran hugo server, started to listen in :1313 port but nothing is showed there.

I am not clear on what to do after generate the .zip file essentially

Request Timeout 500

Hi I just installed this plugin, then click export to hugo, nothing happend for a while it was just loading then finally throw me to request timeout.

The blog have about 200 post, any clue?

thanks

Exported .zip file turns into a .cpgz file when I click on it. Never ending loop.

When I run the exporter it creates a huge-export.zip file. When I click on that (latest version of mac os) it creates a hugo-export.zip.cpgz file which if I click on creates another hugo-export.zip file... in a never ending fashion. Looked into using ditto but it says it can't identify the format.

Are there any exprot logs produced somewhere maybe I can review to see if there was an issue with the export?

the tag format

in the official yaml format of front matter, the tag format is :

tags: ["x", "y"]

but in our export file , the tag is :

tags:

  • x
  • y

so ,i think this need to be improved

Turn 'permalink' to 'url'

In order to keep the same URL pattern, I suggest to turn the 'permalink' data from the frontmatter to "url', so that the same links will be generated.

Export drops the time of posts

With multiple posts on the same date the order gets mixed up.

Changing
return date('Y-m-d', $unixTime);
to
return date('c', $unixTime);
in
function _getPostDate [...]

fixed the issue for me.

Not sure about the other implications, so not creating a pull request.

Fatal error: Maximum execution time of 30 seconds exceeded

Hello,

I am hosting my blog on Dreamhost and now, am planning to migrate to hugo. When I tried to export using "wordpress-to-hugo-exporter" plugin then I got the error below.

Fatal error: Maximum execution time of 30 seconds exceeded in /home/mysite/wp-admin/includes/class-wp-filesystem-direct.php on line 231

I downloaded the "wordpress-to-hugo-exporter" master as zip file and uploaded it from wordpress admin dashboard. I am not sure how to edit "php.ini" since I am on a shared host.

Any idea how to fix it? Thanks in advance.

Memory allocation error when attempting export

I've got a site with 150-200 blog posts to export, hosted on WPEngine, everything up to date version wise.

When I attempt to use the exporter (through the UI as I can't do CLI on this host) I get the following problem:


[Tue Jul 11 19:28:55.301761 2017] [:error] [pid 5633] [client XXXXXX:23529] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 207056397 bytes) in /nas/content/live/itsalocke/wp-includes/functions.php on line 346, referer: https://itsalocke.com/wp-admin/tools.php
--
[Tue Jul 11 19:28:55.315880 2017] [:error] [pid 5633] [client XXXXX:23529] PHP Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0, referer: https://itsalocke.com/wp-admin/tools.php

Is there a way I can tweak the export to keep it within 512MB memory?


PS I tried using the Jekyll exporter but that errors in it's own way.

Warning: Invalid argument supplied for foreach() in /nas/content/staging/itsalocke/wp-includes/class-wp-list-util.php on line 153

Fatal error: Uncaught exception 'Symfony\Component\Process\Exception\RuntimeException' with message 'The Process class relies on proc_open, which is not available on your PHP installation.' in /nas/content/staging/itsalocke/wp-content/plugins/jekyll-exporter/vendor/symfony/process/Process.php

CLI does not produce a valid zip file

Output of php hugo-export-cli.php > export.zip give the following error when trying to unzip export.zip

Archive:  export2.zip
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
unzip:  cannot find zipfile directory in one of export2.zip or
        export2.zip.zip, and cannot find export2.zip.ZIP, period.

using PHP 5.4.20 on wordpress 4.0

I tried with jekyll exporter and that worked without issues.

No content exported

Works fine for front matter but I'm getting nothing for the content area. Any ideas?

White Screen?

Hi,

I've just installed the 1.8 release to my Wordpress 4.9.6 site. Once the plugin is installed, the 'Export to Hugo' entry shows up in the Tools menu. However, clicking on the menu item just leads to a white screen.

I've checked the settings for php 7.0, and it looks like the zip module is loaded.

Any tips on how to debug this?

<code> tag conversion issue

The html codes such as <p> and <br/> generated probably by wordpress should be removed from the text inside <code> tag.

For example: I have this in my wordpress blog.

<code>
int count = 1;
Console.WriteLine(count);
</code>

That code has been converted as below.

`

int count = 1;
Console.WriteLine(count);

`

Is it an known issue? How do I fix it?

Plugin activation fails on Wordpress 4.7.3

When I try to activate the plugin I get the error, "Plugin could not be activated because it triggered a fatal error.", details of the error:
Parse error: syntax error, unexpected T_STRING in <root>/wp-content/plugins/wordpress-to-hugo-exporter-master/hugo-export.php on line 202

Exported site not buildable?

Hi, and thank you for this tool!

I'm trying to migrate my blog away from Wordpress. I've successfully exported the ZIP file, however, the resulting site doesn't seem to be close to buildable.

Out of the box, running hugo in the unzipped hugo-export directory, results in:

ERROR 2018/03/02 05:36:15 No 'baseURL' set in configuration or as a flag. Features like page menus will not work without one.
Total in 6 ms
Error: Error building site: No source directory found, expecting to find it at /home/vladimir/work/blog/hugo-export/content

Fixing the immediate errors (changing url to baseURL in config.yaml, and creating the content directory) causes hugo to execute successfully, but it still does not generate any HTML files - only some XML files containing blank ATOM feeds. None of the exported blog posts seem to have been picked up.

Are there any additional steps that one must do after the export?

I noticed that when following the instructions for creating a new site on https://gohugo.io/getting-started/quick-start/ , the resulting directory structure is quite different from that generated by this exporter. For example, the exported ZIP file has about, index, posts, topics and wp-content directories, whereas the new Hugo site template has archetypes, content, data, layouts, static, and themes directories, and none of those are present in the other. The configuration file is also .toml instead of .yaml - it's as if the two are for different tools entirely.

Perhaps something changed in a breaking way in hugo itself?

Edit: Well, I figured it out - the missing step was to move all the files, except the configuration, to an existing Hugo site skeleton's content directory. I'll leave this open as it seems there are some actionable points mentioned above, but feel free to close at your discretion. Thanks!

can't activate plugin

Hello,
I uploaded this plugin to wp, but cant activate it on the dashboard.
i got thls error:

Parse error: syntax error, unexpected T_STRING in /home/u89339/orangefrog.ru/www/wp-content/plugins/wordpress-to-hugo-exporter/hugo-export.php on line 221

thank for any ideas,
Alexandr Gakhov

Error "Cannot redeclare class Hugo_Export" on cli

ubuntu@ip-172-30-2-183:/var/www/html/wp-content/plugins/wordpress-to-hugo-exporter$ php hugo-export-cli.php
PHP Fatal error:  Cannot redeclare class Hugo_Export in /var/www/html/wp-content/plugins/wordpress-to-hugo-exporter/hugo-export.php on line 28

Memory Exhausted While Exporting BLog

While exporting a large WordPress blog, I get the following error:
PHP Fatal error: Allowed memory size of 4294967296 bytes exhausted (tried to allocate 1512064064 bytes) in /var/www/blogs/blog_com/blog/wp-content/plugins/wordpress-to-hugo-exporter-1.5.0/includes/markdownify/Converter.php on line 793

I've bumped the memory up to 4G by adding a line to hugo-export-cli.php:
ini_set('memory_limit', '4096M');
but still it fails before completion. Is this a direct result of the size of the blog? Is there another way to export without continually increasing the memory of the process?

Call to undefined function add_action()

Exception thrown when run from command line

$ php hugo-export.php > hugo-export.zip
PHP Fatal error:  Uncaught Error: Call to undefined function add_action() in .../plugins/wordpress-to-hugo-exporter/hugo-export.php:62

$ wp core version --extra
WordPress version: 4.7.5
Database revision: 38590
TinyMCE version:   4.506 (4506-20170408)
Package language:  en_US

$ php -v
PHP 7.1.5 (cli) (built: May  9 2017 16:55:02) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

No content exported after clicking Tools > Export to Hugo

I'm past #18 and hit my next snag - I hope others find this helpful too. At the end of a download, I'm left with a file called hugo-export.zip.download that's tiny. When I try to unzip it, it turns into a .cpgz, which I then unzip into another .zip. This goes on forever.

-rw-r--r--@   1 myusername  mygroup   3.0K Dec 21 10:35 hugo-export.zip
-rw-r--r--    1 myusername  mygroup   1.6K Dec 21 10:35 hugo-export.zip.cpgz

wp-content is not exported

Hi Cyrill,

Do you think that we could add an export of local files (ie. `wp-content' ) so that images and other files can go to the static folder ?

Configure Export Path Format

Hi there,

Great job on this plugin, it works very well for most cases, and I have used it successfully in previous builds.

However, I am hoping you may be able to shed some light on the way the exported .md files for posts are processed.
I have a normal WordPress permalink structure of /year/month/day and as per usual, the markdown frontmatter includes that, as desired.

The individual .md files are prefixed with the following format: Y-m-d- (as noted in the attached screenshot PHP date() function)

current-format

My question is whether I can the export format so that posts are placed in subdirectories like so:

desired-format

So ultimately, upon creation of the the .md files for posts, they are placed in a nested folder format of year/month/day/file-name.md.
I have tried doing so by editing the plugin, editing date format to YY"/"mm"/"dd and running an export locally, but it baulks at exporting the posts.

I am trying to pull these .md files in using GatsbyJS, and while I can rename & place the individual files into the subfolder structure, I have over 300 entries which I'd prefer to avoid editing by hand!

I thought my new format is along the right track, but I shall see whether you have an advisable play in this situation before moving on.

Thank you!

Call to a member function find() on boolean

When using the CLI php hugo-export-cli.php I'm get this error:

PHP Fatal error:  Uncaught Error: Call to a member function find() on boolean in 
/ ... /content/themes/cm/functions/dom-manipulaion.php:41

WP is installed as a submodule, my dir structure:

├── content
│   ├── plugins
│   ├── themes
│   └──uploads -> ../shared/content/uploads
└── wp
    ├── wp-admin
    ├── wp-content
    └── wp-includes

I had to update the two include path in hugo-export-cli.php because WordPress is in ./wp. Could this have something to do with it?

I'm running PHP 7.0.19 and WordPress 4.7.5.

failing on empty directories

Hi!

The loop at line 370, foreach (glob(trailingslashit($dir) . '*') as $path) { is failing to run if there are empty directories on wp-content/uploads/. I'm sorry, but I don't know how to fix it. I deleted all empty directories and filled the directory of current month with a dummy text file.

Thanks, guys.

Plugin not working

I installed this plugin and used it. It downloaded a zip file, but it would not open. When I tried to unzip with 7zip, it told me that hte file was not correctly setup as a zip file. I used the wordpress to jekyll plugin and converted to hugo.

PHP Fatal error: Uncaught Error: Call to a member function export()

Doesn't seem to work for me.

$  wp hugo-export

PHP Fatal error:  Uncaught Error: Call to a member function export() on null in /var/www/html/markrichman.com/wp-content/plugins/wordpress-to-hugo-exporter/hugo-export.php:530
Stack trace:
#0 [internal function]: Hugo_Export_Command->__invoke(Array, Array)
#1 phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67): call_user_func(Array, Array, Array)
#2 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#3 phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(351): call_user_func(Object(Closure), Array, Array)
#4 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(327): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#5 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(334): WP_CLI\Runner->run_command(Array, Array)
#6 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(757): WP_CLI\Runner->_run_command()
#7 phar:///usr/local/bin/wp/php/wp-cli.php(21): WP_CLI\Runner->start()
#8 phar:///usr/local/bin/wp/php/boot-phar.php(5): include('phar:///usr/loc...')
#9 /usr/lo in /var/www/html/markrichman.com/wp-content/plugins/wordpress-to-hugo-exporter/hugo-export.php on line 530
Fatal error: Uncaught Error: Call to a member function export() on null in /var/www/html/markrichman.com/wp-content/plugins/wordpress-to-hugo-exporter/hugo-export.php:530
Stack trace:
#0 [internal function]: Hugo_Export_Command->__invoke(Array, Array)
#1 phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67): call_user_func(Array, Array, Array)
#2 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#3 phar:///usr/local/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(351): call_user_func(Object(Closure), Array, Array)
#4 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(327): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#5 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(334): WP_CLI\Runner->run_command(Array, Array)
#6 phar:///usr/local/bin/wp/php/WP_CLI/Runner.php(757): WP_CLI\Runner->_run_command()
#7 phar:///usr/local/bin/wp/php/wp-cli.php(21): WP_CLI\Runner->start()
#8 phar:///usr/local/bin/wp/php/boot-phar.php(5): include('phar:///usr/loc...')
#9 /usr/lo in /var/www/html/markrichman.com/wp-content/plugins/wordpress-to-hugo-exporter/hugo-export.php on line 530

I also tried this:

$ php hugo-export-cli.php
PHP Fatal error:  Cannot redeclare get_file_description() (previously declared in /var/www/html/markrichman.com/wp-admin/includes/file.php:71) in /var/www/html/markrichman.com/wp-admin/includes/file.php on line 86

Error exporting

Cannot redeclare Markdownify\Converter::handleTag_iframe() in /home/oblac203/public_html/wp-content/plugins/wordpress-to-hugo-exporter-1.8.0/includes/markdownify/Converter.php on line 925

new requirements

this is a great tool!
i think it maybe has the below functions :

  1. add the increment export function
  2. add the config setting that can list the export history and the date.
  3. user can choose total export or increment export.
    if user choose increment export ,the tool will export the content from the last export day.

thansks for the work!

Call to member function export() on null

Got this error when trying to run wp hugo-export

PHP Fatal error:  Uncaught Error: Call to a member function export() on null in /var/www/site/wp-content/plugins/wordpress-to-hugo-exporter-master/hugo-export.php:583

Here's my setup:

PHP binary:     /usr/bin/php7.0
PHP version:    7.0.22-0ubuntu0.16.04.1
php.ini used:   /etc/php/7.0/cli/php.ini
WP-CLI root dir:        phar://wp-cli.phar
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /var/www/site
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 1.4.1

Export fails if wp-content/uploads folder is missing

For some reason or another, I didn't have an uploads folder. I don't recall if I deleted it for non-use or if WordPress only creates it when it is used the first time. Either way, the exporter bailed. I created an empty folder and the export appears to have run properly now.

Parse error: hugo-export.php on line 202

I can't edit the php.ini file where my website is hosted and I get this error when the plugin is activated with Wordpress:

Parse error: syntax error, unexpected T_STRING in /web/htdocs/home/wordpress/wp-content/plugins/wordpress-to-hugo/hugo-export.php on line 202

Are the two things related? Is there a way to fix this other that edit php.ini file?

Thank you.

Export not working with latest Wordpress 4.4.1 Version. Creates File, but is Corrupt.

Hi,

Here's what I did.

  1. Downloaded the repository as a .zip file.
  2. Uploaded it as a .zip file in my WPEngine.com hosted Wordpress blog - WP Version 4.4.1.
  3. Successfully installed and activated the plugin.
  4. Clicked Export to Hugo from the Tools menu.
  5. The export started and it created a 54 mb .zip file in my local windows download folder.
  6. I tried to unzip the .zip file and am getting an error that the file is corrupt.
  7. I tried double-clicking .zip file and when I did that, there's nothing inside.

So the file is getting created, because I can open it in a text editor and see binary characters, and it is about 54 Mb, i.e. not an empty file.

I don't know the PHP and other versions. I think Wpengine.com uses the latest of everything.

high utf8 in title breaks things

I played with exporter the other night and noticed it did not play well with high utf characters.

I had issues with non printable chars (e.g. &#13;), double quotes (&#34;), single quotes (&#39; and &apos;).. in my titles, causing invalid .md files generation, breaking hugo, looking bad (all titles on site contained codes, not characters) etc.

Eg, one blog post had title with – in it (&#8211;). Front matter looked like this:

title: 'Top Gear 03×13 &#8211; BBC camera and editing crew are gods'
author: Daemon
type: post
date: 2009-07-06T08:35:56+00:00
url: /2009/07/06/top-gear-03x13-bbc-camera-and-editing-crew-are-gods/
views:
  - 129
categories:
  - developers journal

This one was causing hugo to break with yaml: invalid trailing UTF-8 octet

Started building sites ...
ERROR 2017/11/10 00:00:59 failed to parse page metadata for "posts/2009-07-06-top-gear-03x13-bbc-camera-and-editing-crew-are-gods.md": yaml: invalid trailing UTF-8 octet
Error: Error building site: Errors reading pages: Error: failed to parse page metadata for "posts/2009-07-06-top-gear-03x13-bbc-camera-and-editing-crew-are-gods.md": yaml: invalid trailing UTF-8 octet for 2009-07-06-top-gear-03x13-bbc-camera-and-editing-crew-are-gods.md

Other high ut8 chars just looked like codes in titles in generated code.

I created PR #49

Thanks for great work!
Best!

Exporter stripping iframes.

Any iframes in a post or page are being stripped out when exported. Other HTML is left in, so shouldn't iframes be left in as well? This could possibly be a Wordpress or Markdownify issue as well.

`mkdir` fails for nested uploads

I had some problems with nested upload dirs:
uploads/YYYY/MM/$filename

wp_filesystem->mkdir doesn't recurse (like mkdir -p) so I changed the plugin like this:

diff --git a/hugo-export.php b/hugo-export.php
index 5bde326..5651fd6 100644
--- a/hugo-export.php
+++ b/hugo-export.php
@@ -474,7 +474,9 @@ class Hugo_Export

         // Make destination directory
         if (!is_dir($dest)) {
-            $wp_filesystem->mkdir($dest);
+            if (! wp_mkdir_p($dest)){
+                $wp_filesystem->mkdir($dest) or wp_die("Could not created $dest");
+            }
         }

         // Loop through the folder

To get it working

Call to member function export() on null: solution

This issue was closed, but in fact the solution is to include the line

global $je;

in the file hugo-export.php just before the line $je = new Hugo_Export();. For some reason php (or at least version 5.6) seems to have trouble with global variables.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.