Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Migrating from WordPress, need to preserve category-specific URLs

Solved by Getoar Mjeku View solution

Started by Getoar Mjeku 8 years ago · 5 replies · 627 views
8 years ago

I maintain a multiauthor blog with WordPress. The site has several blog categories, a general blog page that displays all posts, and a few special pages (such as "About"). Posts use this URL format: site.org/category/post-title.

Is there a way to migrate to Grav and preserve the following?

  • author information
  • post categories
  • general blog page that displays all posts (from all categories)
  • URLs that show category (category/post-title)

I'm trying to migrate this site: Plisi.org. I would've switched to Grav long ago, but keeping the URLs intact and having a general blog page is extremely important. Thank you very much.

8 years ago

There's no magic button. It's absolutely possible, but you'll need to get your hands dirty.

To start, here's what the docs say: https://learn.getgrav.org/migration/wordpress.

Here's the link to the export tool: https://github.com/SiteBeez/wordpress-wp2grav-markdown-exporter.

I still needed to munge the markdown to make it work just the way I wanted, but if you have a good text editor that supports regular expressions, it should be relatively straightforward.

And of course you still need to configure your themes and site config. But this will at least preserve your content.

8 years ago

Thank you very much. I got the WP2Grav plugin. I'm still trying to figure out how to maintain category-specific URLs.

1. One way might be to get the blog home page to display posts from category folders. My "pages" folder currently contains subfolders for each category. It looks something like this:

  • pages/category1/post-title-1
  • pages/category1/post-title-2
  • pages/category2/post-title-1
  • pages/category2/post-title-2

I got Grav to show a link to the category folder, but I can't get it to show the actual posts right away.

2. Another way might be to update slugs to <category/post-title>, and keep all posts in the "pages" folder. Not an ideal solution, but something to consider.

3. The Knowledge Base theme does something similar to what I want. Post titles grouped by category appear on the home page. But I'd prefer a blog layout with post titles and a post preview.

Thank you again!

8 years ago

While I don't use child folders personally, my understanding is that it works fine to have a structure as you describe. You could create index pages at each level using page collections.

The only "problem" with your approach is that it assumes a one-to-one relationship between a category and an article (or that you're symlinking articles in multiple categories). You can combine Grav's taxonomy system with page collections to keep your articles in a single folder but still create category-specific indexes. See my Knowledge Base theme for an example.

8 years ago Solution

Thank you very much. I believe updating the page collection to show "@root.descendants" will do the trick.

P.S. It did work. And thank you so much for the Knowledge Base theme. I might still consider using it (with some tweaks) because it's awesome. I'm not a professional, so you've really helped me with this project.

last edited 06/30/18 by Getoar Mjeku
8 years ago

I'm glad you found it useful. Hack away.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 55 13 hours ago
Support · by Anna, 3 days ago
2 60 15 hours ago
Support · by Justin Young, 16 hours ago
1 31 16 hours ago
Support · by Duc , 1 week ago
2 65 5 days ago
Support · by Colin Hume, 1 week ago
2 58 5 days ago