This seems really basic and yet I've been searching for it and can't find anything. I'm working on converting an old legacy/proprietary blog I have into Jekyll. So far it's going well and I have most things working well. I've run into an issue with generating indexs per date.
I'd like to have something like the following:
http://example.org/2012/01/03
http://example.org/2012/02/02
etc...
Where each of those paths pulls up a listing of posts for that date. So on the Jekyll side, I'd guess I'd see something like:
_site/2012/01/03/index.html
_site/2012/02/02/index.html
etc...
...where I can specify a template for generating those listing pages. How do you go about doing this in Jekyll?
Turns out there was already a plugin for this solution:
https://github.com/jekyll/jekyll-archives/
I simply followed the documentation and creating a configuration like the following:
jekyll-archives:
enabled: ['day']
layout: 'archive'
permalinks:
day: '/:year/:month/:day/'
Related
In my Jekyll site I have a permalink structure like this in _config.yml:
permalink: /blog/:title:output_ext
And I have two posts (in _posts) that resolve to the same permalink silently, for example:
2020-10-15-my-post.md
2020-10-16-my-post.md
Only one is written to _site/blog/my-post.html.
Is there a way to halt the building of the site, and throw an error, if two posts resolve to the same permalink (and then, one post overwriting the other)?
The Jekyll CLI has a command called doctor that outputs any deprecation or configuration issues with your site and, among other things, it detects when two posts resolve to the same permalink.
You can run it similarly to how you build your site today:
bundle exec jekyll doctor
In the example you gave in your question, jekyll doctor will show you an error message about a conflict between two pages, similar to this:
Configuration file: /your-website/_config.yml
Jekyll Feed: Generating feed for posts
Conflict: The URL '/your-website/_site/blog/my-post.html' is the destination
for the following pages: /your-website/_posts/2020-10-15-my-post.md,
/your-website/_posts/2020-10-16-my-post.md
When jekyll doctor finds a conflict like the above, its exit code will be non-zero which you can use to fail the build.
I previously used an old CMS.
I moved to wordpress and I've done a lot of work, but I still have in my very old articles 1000+ internal links pointing to old urls.
I've set up redirects, but I would like to actually replace / delete the very old internal linking in the wordpress database.
I have 3 types of old linking :
/articles.php?lng=fr&pg=425 .......... so like /articles.php?stuff
/news.php?lng=fr&pg=1827 .......... so like /news.php?stuff
/2456-actualite .......... so like /id-actualite
I believe that "Search and replace" and "Better search and replace", both Wordpress plugins are only dealing with exact urls, while the ids are dynamic.
How would you delete those all links in the database, but keeping the hypertext of those links?
Thanks !
Have you tried using WP Cli?
It's a very powerful tool for this kind of problems by running some commands on your server.
Example:
# Search and replace but skip one column
$ wp search-replace 'http://example.dev' 'http://example.com' --skip-columns=guid
Have a look more on their search-replace command.
It is probably impossible to change each URL by hand.. much better way is to use something like this "https://wordpress.org/plugins/search-and-replace/" to replace all URLs you need in the database. - This does not only deal with urls but with any other text too.
Every year we update our posts with new data. For example, the best places to live in 2018.
I am trying to write a python script this year that updates the post_content in mysql so we don't have to do a bunch of copying and pasting into the html post editor.
However, as a test, I manually updated wp_post in phpmyadmin for one article. After updating, the following happens:
The mysql table correctly updates. I can export the table with the changes and they are all in there.
The LIVE article is updated.
However, when I go to edit the article in wordpress's post editor, it's still showing the previous version.
Therefore, if I save the post in post editor, it will revert back to the old version.
I am completely out of ideas. I've been googling for hours and no one seems to
have this problem.
More background on my setup:
Wordpress version 4.9.1
Using dreampress from dreamhost as the host
Here's a link to the working page:
https://www.homesnacks.net/best-places-to-live-in-georgia-122131/
Ended up hooking into the wordpress API:
https://developer.wordpress.org/rest-api/
And these tutorials helped
https://www.cloudways.com/blog/setup-and-use-oauth-authentication-using-wp-rest-api/
https://discussion.dreamhost.com/t/authenticating-to-the-wordpress-api-using-oauth-1-0a-server/65094
I have a documentation project made with MkDocs. I would like to define global variables in the configuration file (mkdocs.yml) to be used in the markdown pages (*.md).
Reading this issue, it seems it can be done by including an extra configuration in the mkdocs.yml file, for example:
extra:
version: 1.0
... and then, use that variable in page for example as follows:
---> My version: {{ config.extra.version }}
I tried that, but unfortunately it is not working in my example (no variable substution):
Am I doing something wrong?
Is is possible to make this work?
No, this is not possible at this time.
You say that you "use that variable in page". I'm assuming you mean a "Markdown" page. At this time template variables are not available in the Markdown pages. The template engine is not even run against the Markdown. The output of the Markdown parser is one of the variables passed to the template. For a more detailed explanation of how that works, see my answer to How do you include flask/jinja2 code inside a markdown file?.
Specific to MkDocs, there is an open issue (#304) discussing adding a feature to support some limited templating within the Markdown pages, but it is scheduled for post-1.0, so its not a top priority at this time.
The given answer is out of date as this can be done with plugins like macros or markdownextradata as mentioned above except you would just reference {{ version }}.
As an update, it is possible to insert the variables from the extra slot in mkocs.yml, exactly as you describe.
To make this work, you need to install the markdownextradata plugin.
Does Jekyll support setting multiple permalinks?
For example, I currently have the following in my _config.yml:
permalink: /:categories/:title/
What I would like to have, is the following:
permalink:
- /:categories/:title/
- /:year/:month/:day/:title/
What I'm trying to achieve it that a single post will have multiple URLs. I'm well aware that I can use the "redirect_from" plugin (I'm hosting in GitHub Pages), but that would require me to manually update all my posts to include the redirect_from in the YAML
have you checked out jekyll-archives? https://github.com/jekyll/jekyll-archives
you can create other permalinks like
permalinks:
year: '/:year/'
month: '/:year/:month/'
day: '/:year/:month/:day/'
tag: '/tag/:name/'
category: '/category/:name/'
i don't think you can use :title though. it's an index page that lists posts.