getzola / zola

A fast static site generator in a single binary with everything built-in. https://www.getzola.org
https://www.getzola.org
MIT License
13.99k stars 964 forks source link

Add section option to exclude it from URL #608

Closed jonblack closed 3 years ago

jonblack commented 5 years ago

I like to organise my content on disk using folders for different year and month. I don't need this in the URL. It would be nice to add a section front-page-matter option such as include_in_url (true/false) to denote whether it's part of the URL.

Keats commented 5 years ago

Hmm I'm not sure I want to add that, it makes generating URLs harder with more potential conflicts for a pretty niche usecase.

Leaving it open to get more feedback

backwardspy commented 5 years ago

I am looking at using Zola for a webcomic project. I would like to store the comic's chapters inside their own directories, and I would like to avoid having these directories appear in the URL.

My reasons for wanting this are twofold:

  1. I can generate a chapter list by looking at subsections of the chapters directory, and a page list by looking at pages in each chapter directory.
  2. From an organisational standpoint it seems tidier than having the pages at the top level.

Example (omitting _index.md files)

content
^-- comicname
    ^-- ch1
        ^-- 1.1.md      -> comicname.com/1.1
        ^-- 1.2.md      -> comicname.com/1.2
    ^-- ch2
        ^-- 2.1.md      -> comicname.com/2.1
^-- archive.md          -> comicname.com/archive

From reading the documentation and #413 I thought transparent = true in the section front matter would give me this behaviour. Setting the comicname and ch1/ch2 sections as transparent seems to make it treat them as top-level sections/pages, however the URLs for each page remain the same (/comicname/ch1/1.1 et cetera.)

The remaining option would be setting the path in each page's front matter. This isn't too much trouble, but I would certainly prefer an automated solution if possible.

Keats commented 5 years ago

transparent solves a different issue: when you have your blog posts in a blog/ folder for example but still want to paginate/show them on the homepage. In that case you do want to keep the section path sometimes so it cannot replace a new potential option. Having this option would mean that a page needs to have access to all its ancestors section (since this option could be at any level) to make a link. Not a blocker, just a bit annoying.

Keats commented 3 years ago

Not a lot of support for that feature, closing.

patmaddox commented 1 year ago

Hi there, I wonder if you will re-consider this. For me, this is one of the big missing features from static site generators (I realize if they're all missing it, it's a "me" thing :) I want to have most/all of my pages have top-level URLs, but I don't want a single content/ dir with tons of files.

I group similar files in dirs, either by theme or by how I'm working with them (e.g. seed, develop, solid to represent different stages of development). This feature would let me do that with zola.

The closest approach I have right now is to keep a separate dir of files organized how I want, and then use a Makefile to dump them all into content/.