jekyll / jekyll-redirect-from

:twisted_rightwards_arrows: Seamlessly specify multiple redirections URLs for your pages and posts.
MIT License
782 stars 114 forks source link

Redirect page is processed as Markdown #114

Closed benbalter closed 7 years ago

benbalter commented 8 years ago

Steps to reproduce

  1. Create a document (e.g., post)
  2. Add the following YAML front matter:

    redirect_to: /foo/

Expected

Generated redirect output has a valid <doctype> tag.

Actual:

Doctype tag is HTML entity encoded and appears in the rendered page.

pathawks commented 8 years ago

I can add that this only happens when the document is not HTML. If the document has an .md extension, Jekyll will process it as Markdown, and the Markdown processor will mangle the <!DOCTYPE> tag.

pathawks commented 8 years ago

When a document has been loaded from a file with a .md extension, Jekyll will recognize that this file needs to be fed through a Markdown converter. The issue comes when the document contains redirect_to in the YAML front matter. We replace the content of the document with our redirect page, and can override the layout key so that no other layout is applied, but if the original document had a .md extension then Jekyll will still try to process the page as Markdown.

I do not know how to convince Jekyll not to convert a Convertible once it has been loaded. There is no way to change the file extension of an already loaded Document.

Any ideas, @jekyll/core?

parkr commented 8 years ago

@pathawks Do you know why HTML is even parsed this way by kramdown? It usually allows HTML to pass through.

pathawks commented 8 years ago

That's a good question; I do not know the answer.

parkr commented 8 years ago

Should we just document this and live with it? A bit sad but it seems outside of our hands.

benbalter commented 8 years ago

Should we just document this and live with it? A bit sad but it seems outside of our hands.

The problem is, out of the box, our default template does not work with documents. Could we remove the doctype declaration entirely?

pathawks commented 8 years ago

The problem is, out of the box, our default template does not work with documents.

It's just a Markdown issue, right? Renaming the file to have an .html extension fixes the issue.

Our redirect template is designed to be served as is, without mangling from Markdown or any other processor. Removing the doctype would fix this problem, but there is no guarantee that other problems won't arise with other Markdown processors or future updates to Kramdown.

If there is no way to bypass Jekyll's converters entirely, it seems to be that the best solution is to document that users must use .html for redirect pages, and possibly warn users at build time if a redirect page does not have an .html extension.

benbalter commented 8 years ago

Renaming the file to have an .html extension fixes the issue.

Duh. Not sure why I didn't think of that. If it has no content, it shouldn't be an issue.

parkr commented 8 years ago

If there is no way to bypass Jekyll's converters entirely, it seems to be that the best solution is to document that users must use .html for redirect pages, and possibly warn users at build time if a redirect page does not have an .html extension.

❤️ these two suggestions.

jekyllbot commented 8 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

benbalter commented 8 years ago

If there is no way to bypass Jekyll's converters entirely, it seems to be that the best solution is to document that users must use .html for redirect pages, and possibly warn users at build time if a redirect page does not have an .html extension.

Still outstanding.

jekyllbot commented 7 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

benbalter commented 7 years ago

I think this should be fixed on master after #131.

parkr commented 7 years ago

@benbalter If it is, would you please ship a quick test? :)

jekyllbot commented 7 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

parkr commented 7 years ago

@pathawks, maybe you could ship a quick test? ❤️

jekyllbot commented 7 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

benbalter commented 7 years ago

This issue needs a test to confirm redirect pages are processed as non-munged HTML before it can be closed.

parkr commented 7 years ago

If you add the pinned label, jekyllbot will stop trying to close it.

If you submit a PR to add a test & merge it, jekyllbot won't see this as open anymore :trollface: 😜

jekyllbot commented 7 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.