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

config.toml contains both default language specific information warning incorrectly displays for any multilingual site #2137

Closed
justint opened this issue Mar 11, 2023 · 9 comments

Comments

@justint
Copy link
Contributor

justint commented Mar 11, 2023

Bug Report

Environment

Zola version: zola 0.17.1

Expected Behavior

Warning: config.toml contains both default language specific information at base and under section `[languages.en]`, which may cause merge conflicts. Please use only one to specify language specific information

This warning should only display whenever the condition it describes (config.toml containing both default language specific information at base and under another language section) is true.

Current Behavior

This warning currently incorrectly displays any time a site is configured with a [languages.XX] section in the config.toml, even when neither the base section or language section has language specific information.

Step to reproduce

  1. Do a zola init in an empty directory, leave all options to their defaults.

  2. In the config.toml, add empty [languages] and [languages.en] sections, and (optional) remove build_search_index key. You should have this left:

    config.toml
    # The URL the site will be built for
    base_url = "https://example.com"
    
    # Whether to automatically compile all Sass files in the sass directory
    compile_sass = true
    
    # Whether to build a search index to be used later on by a JavaScript library
    # build_search_index = false
    
    [markdown]
    # Whether to do syntax highlighting
    # Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
    highlight_code = false
    
    [languages]
    
    [languages.en]
    
    [extra]
    # Put all your custom variables here
  3. Run zola serve. Note the warning appears even though there's no language-specific information in either the base section or en language section.

@justint
Copy link
Contributor Author

justint commented Mar 11, 2023

I think this is the culprit:

if base_language_options == languages::LanguageOptions::default() {

base_language_options will be:

LanguageOptions { title: None, description: None, generate_feed: false, feed_filename: "atom.xml", taxonomies: [], build_search_index: false, search: Search { include_title: true, include_content: true, truncate_content_length: None, include_description: false, include_path: false, index_format: ElasticlunrJavascript }, translations: {} }

and languages::LanguageOptions::default() is:

LanguageOptions { title: None, description: None, generate_feed: false, feed_filename: "", taxonomies: [], build_search_index: false, search: Search { include_title: true, include_content: true, truncate_content_length: None, include_description: false, include_path: false, index_format: ElasticlunrJavascript }, translations: {} }

feed_filename isn't being set to "atom.xml" by default for languages::LanguageOptions.

I'd be happy to open a PR to fix this, but I'm relatively new to Rust so I don't know the exact fix. Would the right move here be to define a proper default for LanguageOptions?

@Keats
Copy link
Collaborator

Keats commented Mar 11, 2023

We probably need to define a custom impl Default for LanguageOptions. Have a look at components/config/src/config/markup.rs for an example.

@Keats
Copy link
Collaborator

Keats commented Mar 15, 2023

Let me know if you want to do it, I'd like to include that in a release this week

@justint
Copy link
Contributor Author

justint commented Mar 16, 2023

Sure I'd be interested in picking this up. The timeframe for completion would be ideally before Friday?

@Keats
Copy link
Collaborator

Keats commented Mar 16, 2023

Before Sunday should be fine

justint added a commit to justint/zola that referenced this issue Mar 17, 2023
justint added a commit to justint/zola that referenced this issue Mar 17, 2023
Keats pushed a commit that referenced this issue Mar 17, 2023
@Keats Keats closed this as completed in d52a071 Mar 19, 2023
@voidzero
Copy link

voidzero commented Jun 21, 2023

Hi, I'm getting this issue and since I'm very new to zola, I have no idea what to do. What I'm doing pretty much is that I took https://github.com/gersonbenavides/ataraxia-zola and https://github.com/gersonbenavides/gersonbenavides.github.io and I'm now trying to copy stuff one by one. My default_language is set to en but I'm also using locale = nl_NL and I'm adding [language.nl] and [language.nl.translations]

The error on my console:

Change detected @ 2023-06-21 14:48:50
-> Config changed. The browser needs to be refreshed to make the changes visible.
Warning: config.toml contains both default language specific information at base and under section `[languages.en]`, which may cause merge conflicts. Please use only one to specify language specific information
Checking all internal links with anchors.
> Successfully checked 0 internal link(s) with anchors.
-> Creating 0 pages (0 orphan) and 3 sections
Error: Failed to build the site
Error: Failed to render section '/home/markvd/user/zola/foobar/content/_index.nl.md'
Error: Reason: Failed to render 'index.html': error while rendering macro `menus::top_bar_nav`
Error: Reason: Filter call 'truncate' failed
Error: Reason: Filter `truncate` was called on an incorrect value: got `null` but expected a String

Those errors are probably not related but that warning is.

Sorry for the noobishness of my message.

@voidzero
Copy link

voidzero commented Jun 21, 2023

I have now commented the other languages, only [language.nl] and [language.nl.translations] is remaining. The errors are gone, but still I am getting that warning. What does "language specific information at base" mean?

Warning: config.toml contains both default language specific information at base and under section [languages.nl], which may cause merge conflicts. Please use only one to specify language specific information

edit Ok, apparently I had generate_feed = true defined at the top level, and also in [language.nl]. That triggered the warning. I removed it from the top level and I can now continue on my endeavours.

@Keats
Copy link
Collaborator

Keats commented Jun 22, 2023

apparently I had generate_feed = true defined at the top level, and also in [language.nl]. That triggered the warning. I removed it from the top level and I can now continue on my endeavours.

Exactly, that was the issue. It just warns you something is defined in multiple places but doesn't really tell you what

@rameshchandra8520
Copy link

Those errors are probably not related but that warning is.

I encountered the same errors with ataraxia-zola, but not the warnings since I didn't add any additional languages. However, I discovered that the cause of the error is likely due to having multiple languages specified in the languages section by default, such as "en" and "es". After removing the Spanish language text ("es"), I resolved the error, and now it's working fine.

I kindly request the maintainers of ataraxia-zola to check on this.

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