Skip to content

Instantly share code, notes, and snippets.

@davidmerfield
Created February 6, 2019 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmerfield/1a1413a3ca07040e93e29fe3edc74ec0 to your computer and use it in GitHub Desktop.
Save davidmerfield/1a1413a3ca07040e93e29fe3edc74ec0 to your computer and use it in GitHub Desktop.
A view for a Hugo site to generate a Wordpress export file
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<!-- 4. Activate & Run Importer. -->
<!-- 5. Upload this file using the form provided on that page. -->
<!-- 6. You will first be asked to map the authors in this export file to users -->
<!-- on the site. For each author, you may choose to map to an -->
<!-- existing user on the site or to create a new user. -->
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
<!-- contained in this file into your site. -->
<!-- generator="WordPress/5.0.3" created="2019-02-02 21:54" -->
<rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.2/">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description></description>
<wp:wxr_version>1.2</wp:wxr_version>
<wp:base_site_url>{{.Site.BaseURL}}</wp:base_site_url>
<wp:base_blog_url>{{.Site.BaseURL}}</wp:base_blog_url>
{{ range .Data.Pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
<guid isPermaLink="false">{{ .Permalink }}</guid>
<description></description>
<content:encoded>
<![CDATA[{{ .Content | html }}]]>
</content:encoded>
<excerpt:encoded>
<![CDATA[]]>
</excerpt:encoded>
</item>
{{ end }}
</channel>
</rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment