2

How do I use Jekyll on my local machine to create/edit posts on my remote WordPress blog? More specifically:

  • I want to write posts in plain text, use Jekyll's markup parser to create HTML, and then post the resulting HTML to my WordPress site.

  • If I edit an existing local text file, I want the corresponding WordPress post edited. I don't care if revision history is preserved on WordPress, since I plan on preserving it locally.

Rationale: I really like the idea of having a website stored/generated locally and then mirrored to a server, in part because that was the only way to do things when I first started posting to the Web.

However, I feel Jekyll's lack of comments, trackbacks, and server-side scripting (though JavaScript may suffice) are not quite sufficient for my needs, especially since I want to avoid using third party tools such as Disqus, or even a local version of Disqus that runs in parallel to my blog.

Any help appreciated!

0

I'll suggest you look into the source code used to generate your static files, the Theme in other-words. In the case of Minima that would be the _layouts and _includes directories for what's building most of the templated HTML. Then look into Jekyll's Usage and Configs, specifically the --destination option I think you'll find helpful in targeting a sub-directory within your WordPress site's folder structure.

Getting the look-n-feel to be consistent between pages generated by Jekyll and those built with WordPress is likely to be more than a little fiddly. CSS loading properly, just to name one future issue I believe you'll face. But using the base_url setting within either the main _config.yml or a _config_baseurl.yml (as I've done for my own non-WordPress related project), might allow for bodging something that gets what ya want done.

I'm not suggesting that you pursue hybridizing Jekyll and WordPress, but I think the easiest route will be building to a sub-directory within your WordPress site. However, do be careful as the default jekyll build process removes anything within the --destination directory!

Now if your aim is instead to use server-side scripting within Jekyll built pages (first, how perverse... in a good way...), it would be a good idea to keep file types in mind, eg. .md/.markdown files are tab-sensitive and will have angle-brackets (< and >), among other things parsed through smartify. So doing something like...

---
layout: post
title: Jekyll with PHP test
---

<?php

    echo "Hello World!"

?>


Stuff about things regarding `PHP` and Jekyll

... would, if I remember correctly, output something like...


<?php

echo "Hello World!"

?>

Stuff about things regarding PHP and Jekyll


... because the <?php got translated into &lt;?php, the echo "Hello World!" turned into a code-block, and ?> was transmuted into ?&gt;

Not a good time, so if you must do stuff like that for some reason I'll suggest that you make use of Liquid's raw tags, eg....

{% raw %}
<?php

    echo "Hello World!"

?>
{% endraw %}

... to prevent smartify from getting clever with what you maybe trying to do.

If you could be more specific as to what things you'd need replaced to make a full switch to Jekyll, perhaps others or future revisions of this answer will include more suggestions on that tangent. For now I did see that GitHub has launched Team Discussions and I've heard rumors of those that use Issues almost like a forum.

As for keeping things synced/mirrored between local edits and your remote server, it might be worth looking into git aliases and git hooks, as these may be leveraged for doing things in addition to, or intermixed with, other Git operations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.