Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom default options #634

Open
JadedBlueEyes opened this issue Mar 16, 2019 · 7 comments
Open

Custom default options #634

JadedBlueEyes opened this issue Mar 16, 2019 · 7 comments

Comments

@JadedBlueEyes
Copy link

Feature

Current Problem

Many people have wants and needs that are different to anyone else's, and we can't expect the default's to be perfect for everyone. However, Zola currently isn't very accomodating for sites that don't fit the mould. A big part of this will be things like custom output formats, pagination, and betterout of the box features. However users should also be presented with a way to configure their own defaults. They may want to use a different template for every page in a specific collection, or set a default author for personal blogs. This should be simple and easy.

Description

Jekyll demonstrates what many people would want perfectly. Having a 'defaults' key under config, where you can set what specific file's front matter should default to.

@Keats
Copy link
Collaborator

Keats commented Mar 18, 2019

A big part of this will be things like custom output formats, pagination, and better out of the box features.

Custom output format is being thought of: https://zola.discourse.group/t/proposal-custom-output-formats/68/2

Can you detail what is missing from the current pagination? Rather than putting everything in the config file, configuration happens at the section level. I have never used Jekyll so I might be wrong but it seems it doesn't have the concept fo sections so you have to put it in the configuration instead?

They may want to use a different template for every page in a specific collection

Zola doesn't have collections, do you mean sections? If so, that is already possible

or set a default author for personal blogs.

Zola doesn't have the concept of authors but you can set anything you want in the extra bit of the config: https://github.com/getzola/zola/blob/master/docs/config.toml#L12-L13

@JadedBlueEyes
Copy link
Author

Can you detail what is missing from the current pagination?

Mainly generating multiple pages. #624 describes one usage for this.

If so, that is already possible

How? If I wanted to set the template for all blog articles to "post", and extra.author to "SHYC", how would I do that? It doesn't appear to be documented.

doesn't have the concept fo sections so you have to put it in the configuration instead

Jekyll has collections, what I got mixed up with, that are folders in the root. You can set options for them, and specific pages and patterns, in the config file, but you must store data in seperate files. This means all config is in one place, and the use of YAML makes it quite easy, especialy with the high level of editor support.

@Keats
Copy link
Collaborator

Keats commented Mar 22, 2019

Mainly generating multiple pages. #624 describes one usage for this.

That issue doesn't seem to be about pagination though?

If I wanted to set the template for all blog articles to "post"

The page_template variable described in https://www.getzola.org/documentation/content/section/

and extra.author to "SHYC

For that case, it would be in the config extra (like in my link above) as config is passed in every template rendering.

This means all config is in one place

That doesn't seem really ideal to me, especially when you have many subsections, some transparent. That specific change of putting section level config in config.toml is not going to happen

@JadedBlueEyes
Copy link
Author

That issue doesn't seem to be about pagination though?

Yes, it's not about pagination, or anything else mentioned in that sentance. That chunk of paragraph was mostly context setting though.

The page_template variable

Ahh, ok.
To be honest, though, that seems a bit janky. Perhaps a page_defaults section, that allows for things like this, and extra options, to be set more eligantly?

For that case, it would be in the config extra

Wouldn't that create really janky templates?

{%- set author = page.extra.author | default(value=config.extra.author) -%}

or

{%- if page.extra.author -%}
{{ page.extra.author }}
{%- elif config.extra.author -%}
{{ config.extra.author }}
{%- endif -%}

That doesn't seem really ideal to me, especially when you have many subsections, some transparent. That specific change of putting section level config in config.toml is not going to happen

Fair enough, this is more a matter of opinions and preference, but a choice is nice.

@Artoria2e5
Copy link

In the same vain, is there a way to slap a insert_anchor_links onto every section as a default? These sort of settings become annoying to copy-paste when a site ends up with many sections.

@Keats
Copy link
Collaborator

Keats commented Jul 19, 2021

insert_anchor_links could probably be a config option in config.toml

@ctron
Copy link

ctron commented Sep 24, 2023

As I want to migrate from Worpress to Zola, keeping a path structure of yyyy/mm/dd I need to create a "transparent" section for every day. Super annoying. But even more annoying is that it seems I can't add insert_anchor_links on the top section, but need to place it in every section.

I think having this as a default configuration for the site makes total sense.

9999years added a commit to 9999years/zola that referenced this issue Jan 12, 2025
`insert_anchor_links` was a valid `config.toml` setting before [0.0.6]
but was changed to a section option.

[0.0.6]: https://github.com/getzola/zola/blob/master/CHANGELOG.md#006-2017-05-24

It was mentioned in the documentation for `config.toml` until 2021
(getzola#1477).

In 2021, @Keats said that "`insert_anchor_links` could probably be a
config option in `config.toml`":
getzola#634 (comment)

In the same thread, several other users requested this feature.
@Artoria2e5 said:

> These sort of settings become annoying to copy-paste when a site ends
> up with many sections.

@ctron said:

> But even more annoying is that it seems I can't add
> insert_anchor_links on the top section, but need to place it in every
> section.
>
> I think having this as a default configuration for the site makes
> total sense.
9999years added a commit to 9999years/zola that referenced this issue Jan 12, 2025
`insert_anchor_links` was a valid `config.toml` setting before [0.0.6]
but was changed to a section option.

[0.0.6]: https://github.com/getzola/zola/blob/master/CHANGELOG.md#006-2017-05-24

It was mentioned in the documentation for `config.toml` until 2021
(getzola#1477).

In 2021, @Keats said that "`insert_anchor_links` could probably be a
config option in `config.toml`":
getzola#634 (comment)

In the same thread, several other users requested this feature.
@Artoria2e5 said:

> These sort of settings become annoying to copy-paste when a site ends
> up with many sections.

@ctron said:

> But even more annoying is that it seems I can't add
> insert_anchor_links on the top section, but need to place it in every
> section.
>
> I think having this as a default configuration for the site makes
> total sense.
Keats pushed a commit that referenced this issue Jan 21, 2025
`insert_anchor_links` was a valid `config.toml` setting before [0.0.6]
but was changed to a section option.

[0.0.6]: https://github.com/getzola/zola/blob/master/CHANGELOG.md#006-2017-05-24

It was mentioned in the documentation for `config.toml` until 2021
(#1477).

In 2021, @Keats said that "`insert_anchor_links` could probably be a
config option in `config.toml`":
#634 (comment)

In the same thread, several other users requested this feature.
@Artoria2e5 said:

> These sort of settings become annoying to copy-paste when a site ends
> up with many sections.

@ctron said:

> But even more annoying is that it seems I can't add
> insert_anchor_links on the top section, but need to place it in every
> section.
>
> I think having this as a default configuration for the site makes
> total sense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants