can Jekyll process a markdown file and save it somewhere besides <directory>

247 Views Asked by At

Using Jekyll is there a way to save one file to a different directory than what is set in _config.yml as destination?

I'm using Jekyll and github-pages to generate geojson but need that geojson to be saved in a different folder that the rest of the content stored by Jekyll. I need this because I .gitignore the _site folder as recommended but need the .geojson I template out on github to render a map.

2

There are 2 best solutions below

0
On

Check if you need Jekyll to process the markdown page, considering a GitHub page (in markdown) now (March 2022, 7 years later) supports geojson directly:

Mermaid, topoJSON, geoJSON, and ASCII STL Diagrams Are Now Supported in Markdown and as Files

In addition to mermaid diagrams, we now allow users to render maps directly in markdown using fenced code blocks with the geojson or topojson syntax, and embed STL 3D renders using stl syntax.

Additionally, these diagrams are supported as files using their own extensions:

content type supported extensions
mermaid .mermaid, .mmd
geoJSON .geojson, .json
topoJSON .topojson, .json
STL .stl

Example: geojson

```geojson
{
  "type": "Polygon",
  "coordinates": [
      [
          [-90,30],
          [-90,35],
          [-90,35],
          [-85,35],
          [-85,30]
      ]
  ]
}

gives:

https://i0.wp.com/user-images.githubusercontent.com/7219923/158465928-cbe9d7b4-71dd-4f6a-8e2b-9a3ded2c1edf.png?ssl=1

0
On

Jekyll process all content of your site into the _site folder. You can change the name of this folder, but I don't think this is what your question was.

If you want to relocate your file within the _site folder you can use permalink in your file's front matter.

If you just need the GFM then you may want to use another tool rather than Jekyll. Example here