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

After generate the paginated page I get weird tags included #1482

Closed
ckissi opened this issue Oct 29, 2020 · 7 comments
Closed

After generate the paginated page I get weird tags included #1482

ckissi opened this issue Oct 29, 2020 · 7 comments

Comments

@ckissi
Copy link

ckissi commented Oct 29, 2020

In dev as well as in production I'm getting weird tags included for the paginated page.

image

code for the page looks like this:

---
permalink: theme/index.html
layout: layouts/base.njk
pagination:
  data: collections.theme
  size: 10
---
<ol>
{%- for theme in pagination.items -%}
<li>{{ theme.data.name}}</li>
{%- endfor -%}
</ol>

Code of the layout file:

<!doctype html>
<html lang="en" class="no-js">
<head>
  <meta charset="utf-8">
  <script>
    document.documentElement.className = document.documentElement.className.replace(/\bno-js\b/g, '') + 'has-js ';
  </script>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="{{ renderData.description or description or metadata.description }}">
  <meta name="generator" content="Eleventy">

  <title>{{ renderData.title or title or name or metadata.title }}</title>

  <link rel="stylesheet" href="/styles/index.css">
</head>

<body class="w-full p-0 m-0 font-sans" style="background-color:#f7f8f9" id="top" itemscope itemtype="http://schema.org/WebPage">
  {% include 'components/header.njk' %}
  <div class="container flex flex-col mx-auto mt-5 md:flex-row">
    {{ content | safe }}
  </div>
  {% include 'components/footer.njk' %}
  <script src="/scripts/index.js"></script>
</body>
</html>

Running on MacOS Catalina + Eleventy 0.11.0

@edwardhorsford
Copy link
Contributor

@ckissi can you share the contents of footer.njk? My initial guess would be that it contains a bug / unclosed script tag or something.

@ckissi
Copy link
Author

ckissi commented Oct 29, 2020

<footer>
    <div class="flex justify-center">
        <div>Made by <a href="#">Me</a></div>
    </div>
</footer>

It happens if I remove the header and footer include from the layout file as well. So it must be something else.

@ckissi
Copy link
Author

ckissi commented Oct 30, 2020

@edwardhorsford The problem was that the permalink was no dynamic and it seems like the page was always theme/index.html

Seems that the page is not overwritten but like the HTML code is injected in it. So if the last generated page HTML was small in size than the previous one it's causing the part of HTML of the previously generated page for the same permalink will stay visible.

I changed the permalink to this:
permalink: plugin{% if pagination.pageNumber > 0 %}/page{{ pagination.pageNumber + 1}}{% endif %}/index.html

and it works now.

@ckissi ckissi closed this as completed Oct 30, 2020
@edwardhorsford
Copy link
Contributor

edwardhorsford commented Oct 30, 2020

Good catch. Did you get an error about writing to the same file multiple times? If not that would seem a good thing for Eleventy to output.

@ckissi
Copy link
Author

ckissi commented Oct 30, 2020

Good catch. Did you get an error about writing to the same file multiple times? If not that would seem a good thing for Eleventy to output.

No error man. Everything seemed to be OK. It would be definitely a great feature to show this.

@edwardhorsford
Copy link
Contributor

@zachleat might be something to look at? I presume most cases of pagination writing to the exact same permalink are likely mistakes.

@Ryuno-Ki
Copy link
Contributor

Ryuno-Ki commented Nov 1, 2020

Shouldn't that be catched by #562 already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants