Hello. Is there a way to generate multiple files for each post (or collection page)?
For example, I have a post Test_Post.md
, and from it, I would like to generate:
- The standard HTML page with includes, layout, etc…
- A “Test_Post.txt” text version, with the original markdown, plus a header, footer, etc…
- An SVG image with description, header info, etc… To be used in social meta tags.
- and more…
I know I can do one of these things at a time, but how to do them all from one file?
I’m not asking how to code or design these things, I just want to know if there is a way to do this natively in Jekyll without creating 3 copies of Test_Post.md
.
Thank you in advance!
If your first bullet I understand correctly, that is the standard behavior and so requires nothing more to make HTML.
The second point can be covered by a generator - see plugins in the docs. It would find md files and write out a txt using the content and dropping frontmatter. What is your purpose for doing this? It will lack any styling and metadata so is not useful in the browser.
If you want plain text of your entire site you can also consider using Jekyll to make a JSON file at the root of your repo which contains the plain text content of every page in your site in an array or hash. That can be used for JS like for searching the site.
What is that SVG image of? Is it a screenshot of the page?
Consider using the Jekyll SEO tag to take care of your metadata and OpenGraph metadata for social sharing. Facebook has a free debugger that lets you preview what appears when sharing.
I don’t know if making an SVG is worthwhile. Do some research like seeing how other sites embed and you’ll find I think that their is a favicon or a higher res version which is used for any page that is shared plus title and description.
Consider the open graph website as well for info on what you need to do. For example in repo settings you can upload a a social image of certain dimensions that is a PNG. So that format must be acceptable and it is done as one image for the entire repo.
Anyway you can use some Jekyll plugin you find or write to make SVGs in general. You’ll have to figure out what is in the SVG and how to automatically generate it.
@MichaelCurrin Thank you for your posts! However, I don’t need to figure out how to do each of the bullets. I can already accomplish everything I need if I have three duplicate directories, but I would like to know if there is a way to have multiple collections in the same path. For example, the files in the _projects
directory would be outputted to three versions of files. Is there a way to do this?
By the way, the text file is not for the browser, it is for a terminal client I am writing. The SVG will just be the open graph image, I chose SVG because it is text based and can be easily created in Jekyll. It will just contain the header image, the description, and the date.
What I am thinking about doing now is just duplicating the _projects
directory twice before running Jekyll, and then ending up with _projects
, _projects2
, and _projects3
. However, I just would prefer doing this in Jekyll.
1 Like
If you are happy with duplicating exactly, you can add shortcuts.
So
project1 # original
project2 # symlink to project1
project3 # symlink to project1
Or run three steps against a single project directory. One plain Jekyll and the other 2 as shell commands that output to _site
.
You can also use a generator plugin so that when you build or serve with Jekyll, your txt and SVG logic runs as the same time. Either in the same output directory or a new one of just txt and another of just SVG
Thank you! That works well, I hadn’t thought of using symlinks!
1 Like