-
Notifications
You must be signed in to change notification settings - Fork 1k
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
check_internal_links_with_anchors crashes on multilinguial website #1694
Comments
Display more advanced information in case of a future crash here
…la#1694 It appears linking to another translated page does not trigger the bug, but linking to a section within the same (translated) page does.
So #1780 was merged with the fix. Thanks for the report and the suggested fix! And thanks for merging so quickly! Leaving this note here in case someone wonders why pages containing I initially wanted to check if the path contained @Keats i forgot to update the changelog in the PR, could you take care of it maybe? however small it is i believe this new limitation in page names should be documented as a "breaking change" which will likely affect nobody but still |
…ence content files without using `get_url`. # Aider chat conversation: USER: I think the use of get_url is incorrect, see: https://www.getzola.org/documentation/content/page/ https://www.getzola.org/documentation/content/page/: [Zola](https://www.getzola.org/) - [Docs](https://www.getzola.org/documentation/) - [Themes](https://www.getzola.org/themes/) - [Forum](https://zola.discourse.group/) - [GitHub](https://github.com/getzola/zola) - Getting Started - [Overview](https://www.getzola.org/documentation/getting-started/overview/) - [Installation](https://www.getzola.org/documentation/getting-started/installation/) - [CLI usage](https://www.getzola.org/documentation/getting-started/cli-usage/) - [Directory structure](https://www.getzola.org/documentation/getting-started/directory-structure/) - [Configuration](https://www.getzola.org/documentation/getting-started/configuration/) - Content - [Overview](https://www.getzola.org/documentation/content/overview/) - [Section](https://www.getzola.org/documentation/content/section/) - [Page](https://www.getzola.org/documentation/content/page/) - [Shortcodes](https://www.getzola.org/documentation/content/shortcodes/) - [Internal links & deep linking](https://www.getzola.org/documentation/content/linking/) - [Table of Contents](https://www.getzola.org/documentation/content/table-of-contents/) - [Syntax Highlighting](https://www.getzola.org/documentation/content/syntax-highlighting/) - [Taxonomies](https://www.getzola.org/documentation/content/taxonomies/) - [Search](https://www.getzola.org/documentation/content/search/) - [Sass](https://www.getzola.org/documentation/content/sass/) - [Image processing](https://www.getzola.org/documentation/content/image-processing/) - [Multilingual sites](https://www.getzola.org/documentation/content/multilingual/) - Templates - [Overview](https://www.getzola.org/documentation/templates/overview/) - [Sections and Pages](https://www.getzola.org/documentation/templates/pages-sections/) - [Pagination](https://www.getzola.org/documentation/templates/pagination/) - [Taxonomies](https://www.getzola.org/documentation/templates/taxonomies/) - [Feeds](https://www.getzola.org/documentation/templates/feeds/) - [Sitemap](https://www.getzola.org/documentation/templates/sitemap/) - [Robots.txt](https://www.getzola.org/documentation/templates/robots/) - [404 error page](https://www.getzola.org/documentation/templates/404/) - [Archive](https://www.getzola.org/documentation/templates/archive/) - Themes - [Overview](https://www.getzola.org/documentation/themes/overview/) - [Installing & using themes](https://www.getzola.org/documentation/themes/installing-and-using-themes/) - [Creating a theme](https://www.getzola.org/documentation/themes/creating-a-theme/) - [Customizing a theme](https://www.getzola.org/documentation/themes/extending-a-theme/) - Deployment - [Overview](https://www.getzola.org/documentation/deployment/overview/) - [Sourcehut Pages](https://www.getzola.org/documentation/deployment/sourcehut/) - [Netlify](https://www.getzola.org/documentation/deployment/netlify/) - [GitHub Pages](https://www.getzola.org/documentation/deployment/github-pages/) - [GitLab Pages](https://www.getzola.org/documentation/deployment/gitlab-pages/) - [Edgio](https://www.getzola.org/documentation/deployment/edgio/) - [Vercel](https://www.getzola.org/documentation/deployment/vercel/) - [Zeabur](https://www.getzola.org/documentation/deployment/zeabur/) - [Cloudflare Pages](https://www.getzola.org/documentation/deployment/cloudflare-pages/) - [Fly.io](https://www.getzola.org/documentation/deployment/flyio/) - [AWS S3 Bucket](https://www.getzola.org/documentation/deployment/aws-s3/) - [Docker image](https://www.getzola.org/documentation/deployment/docker-image/) # Page A page is any file ending with `.md` in the `content` directory, except files named `_index.md`. **Note:** page file names must not contain `_index.` [at all](getzola/zola#1694). If a file ending with `.md` is named `index.md`, it will generate a page with the name of its directory (for example, `/content/about/index.md` would create a page at `[base_url]/about`). (Note the lack of an underscore; if the file were named `_index.md`, then it would create a **section** at `[base_url]/about`, as discussed in a previous part of this documentation. In contrast, naming the file `index.md` will create a **page** at `[base_url]/about`). If the file is given any name *other* than `index.md` or `_index.md`, then it will create a page with that name (without the `.md`). For example, naming a file in the root of your content directory `about.md` would create a page at `[base_url]/about`. Another exception to this rule is that a filename starting with a datetime (YYYY-mm-dd or [an RFC3339 datetime](https://www.ietf.org/rfc/rfc3339.txt)) followed by an underscore (`_`) or a dash (`-`) will use that date as the page date, unless already set in the front matter. The page name will be anything after `_`/`-`, so the file `2018-10-10-hello-world.md` will be available at `[base_url]/hello-world`. Note that the full RFC3339 datetime contains colons, which is not a valid character in a filename on Windows. This behavior can be disabled by setting `slugify.paths_keep_dates` to `true` (the default is `false`). Note that a `_` separating the date would be slugified into a `-` with the default value for `slugify.paths` of `"on"`. As you can see, creating an `about.md` file is equivalent to creating an `about/index.md` file. The only difference between the two methods is that creating the `about` directory allows you to use asset co-location, as discussed in the [overview](https://www.getzola.org/documentation/content/overview/#asset-colocation) section. ## [🔗](#output-paths)Output paths For any page within your content folder, its output path will be defined by either: - its `slug` frontmatter key - its filename Either way, these proposed path will be sanitized before being used. If `slugify.paths` is set to `"on"` in the site\'s config - the default - paths are [slugified](https://en.wikipedia.org/wiki/Clean_URL#Slug). If it is set to `"safe"`, only sanitation is performed, with the following characters being removed: `<`, `>`, `:`, `/`, `|`, `?`, `*`, `#`, `\\`, `(`, `)`, `[`, `]` as well as newlines and tabulations. This ensures that the path can be represented on all operating systems. Additionally, trailing whitespace and dots are removed and whitespaces are replaced by `_`. If `slugify.paths` is set to `"off"`, no modifications are made. If you want URLs containing non-ASCII characters, `slugify.paths` needs to be set to `"safe"` or `"off"`. ### [🔗](#path-from-frontmatter)Path from frontmatter The output path for the page will first be read from the `slug` key in the page\'s frontmatter. **Example:** (file `content/zines/élevage-chèvre.md`) +++ title = "L'élevage de chèvres, la carrière alternative de tous dévelopeurs'" slug = "élevage-chèvre-carrière-alternative" +++ This is my article. This frontmatter will output the article to `[base_url]/zines/élevage-chèvre-carrière-alternative` with `slugify.paths` set to `"safe"` or `"off"`, and to `[base_url]/zines/elevage-chevre-carriere-alternative` with the default value for `slugify.paths` of `"on"`. ### [🔗](#path-from-filename)Path from filename When the article\'s output path is not specified in the frontmatter, it is extracted from the file\'s path in the content folder. Consider a file `content/foo/bar/thing.md`. The output path is constructed: - if the filename is `index.md`, its parent folder name (`bar`) is used as output path - otherwise, the output path is extracted from `thing` (the filename without the `.md` extension) If the path found starts with a datetime string (`YYYY-mm-dd` or [a RFC3339 datetime](https://www.ietf.org/rfc/rfc3339.txt)) followed by optional whitespace and then an underscore (`_`) or a dash (`-`), this date is removed from the output path and will be used as the page date (unless already set in the front-matter). Note that the full RFC3339 datetime contains colons, which is not a valid character in a filename on Windows. The output path extracted from the file path is then slugified or not, depending on the `slugify.paths` config, as explained previously. **Example:** The file `content/blog/2018-10-10-hello-world.md` will yield a page at `[base_url]/blog/hello-world`. With optional whitespace, the file `content/blog/2021-01-23 -hello new world.md` will yield a page at `[base_url]/blog/hello-new-world` ## [🔗](#front-matter)Front matter The TOML front matter is a set of metadata embedded in a file at the beginning of the file enclosed by triple pluses (`+++`). Although none of the front matter variables are mandatory, the opening and closing `+++` are required. Note that even though the use of TOML is encouraged, YAML front matter is also supported to ease porting legacy content. In this case the embedded metadata must be enclosed by triple minuses (`---`). Here is an example page with all the available variables. The values provided below are the default values. title = "" description = "" # The date of the post. # Two formats are allowed: YYYY-MM-DD (2012-10-02) and RFC3339 (2002-10-02T15:00:00Z). # Do not wrap dates in quotes; the line below only indicates that there is no default date. # If the section variable `sort_by` is set to `date`, then any page that lacks a `date` # will not be rendered. # Setting this overrides a date set in the filename. date = # The last updated date of the post, if different from the date. # Same format as `date`. updated = # The weight as defined on the Section page of the documentation. # If the section variable `sort_by` is set to `weight`, then any page that lacks a `weight` # will not be rendered. weight = 0 # A draft page is only loaded if the `--drafts` flag is passed to `zola build`, `zola serve` or `zola check`. draft = false # If set, this slug will be used instead of the filename to make the URL. # The section path will still be used. slug = "" # The path the content will appear at. # If set, it cannot be an empty string and will override both `slug` and the filename. # The sections' path won't be used. # It should not start with a `/` and the slash will be removed if it does. path = "" # Use aliases if you are moving content but want to redirect previous URLs to the # current one. This takes an array of paths, not URLs. aliases = [] # A list of page authors. If a site feed is enabled, the first author (if any) # will be used as the page's author in the default feed template. authors = [] # When set to "true", the page will be in the search index. This is only used if # `build_search_index` is set to "true" in the Zola configuration and the parent section # hasn't set `in_search_index` to "false" in its front matter. in_search_index = true # Template to use to render this page. template = "page.html" # The taxonomies for this page. The keys need to be the same as the taxonomy # names configured in `config.toml` and the values are an array of String objects. For example, # tags = ["rust", "web"]. [taxonomies] # Your own data. [extra] ## [🔗](#summary)Summary You can ask Zola to create a summary if, for example, you only want to show the first paragraph of the page content in a list. To do so, add `<!-- more -->` in your content at the point where you want the summary to end. The content up to that point will be available separately in the [template](https://www.getzola.org/documentation/templates/pages-sections/#page-variables) via `page.summary`. A span element in this position with a `continue-reading` id is created, so you can link directly to it if needed. For example: `<a href="{{ page.permalink }}#continue-reading">Continue Reading</a>`. ©2017-2024 --- [Vincent Prouillet](https://www.vincentprouillet.com) and [contributors](https://github.com/getzola/zola/graphs/contributors) ASSISTANT: Based on the Zola documentation, it seems that the use of `get_url` in `templates/index.html` is incorrect. We should update the template to correctly reference the content files. Let's update `templates/index.html` to correctly reference the content files without using `get_url`. Here are the *SEARCH/REPLACE* blocks: templates/index.html ```python <<<<<<< SEARCH <p>Click <a href="{{ get_url(path='@/blog/_index.md') }}">here</a> to see my posts.</p> ======= <p>Click <a href="/blog/">here</a> to see my posts.</p> >>>>>>> REPLACE ``` Please apply these changes and run `zola build` again to see if the issues are resolved.
The error happens here
zola/components/site/src/link_checking.rs
Line 65 in 1ed1fdb
I think this is caused by
if md_path.contains("_index.md") {
in my case, the file is named_index.de.md
as it is in german.If I change the
contains
call forif md_path.contains("_index.") {
the issue seems to be fixed but I am not fully sure this is the correct fix.The text was updated successfully, but these errors were encountered: