Skip to content

Conversation

@maelle
Copy link
Contributor

@maelle maelle commented Dec 1, 2020

Fix #1025

  • A bit hacky
  • Maybe the message on the page should be customizable

@maelle

This comment has been minimized.

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do something for gitbook also and close #1046 too.
I'll take it from here but work on your branch in this PR

@cderv cderv changed the title add 404 page for bs4_book add 404 page for bs4_book and Gitbook Jul 1, 2021
@cderv
Copy link
Collaborator

cderv commented Jul 1, 2021

So I went further with my idea with this.

  • 404.html page is now added in the HTML splitting process. This mean it works for gitbook() and bs4_book()
  • If a 404.html exist in the main repo at the root level with the Rmd files, then it will be used. I don't think this should be used as none of the header, footer and sidebar will be included in this case. This is mainly there to avoid overriding an existing file if it is there. EDIT: then we do nothing and leave it as is. If a user already has a 404.html page then a mechanism is probably in place to move it in output dir (This was changed following a discussion with @apreshill during review)
  • If a _404.Rmd or a _404.md is there, it will be render as a html_fragment and the content will be included as the body of the 404 page. This means all the theme (navbar, footer, sidebars, ...) will be there.
  • If none of the above is there, then a default 404.html is created using a simple content (a header, and a body of 2 paragraphs)
  • Currently, there is no way to opt-in or out of this behavior.

@apreshill before going further with docs and tests, is this something as you imagined ?
We could definitely adapt and simplify.

Demo :

@cderv cderv linked an issue Jul 1, 2021 that may be closed by this pull request
2 tasks
Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes to made following live review with @apreshill

Overall we are good with this feature

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only thing left is documentation in the book.

cderv added 4 commits July 2, 2021 15:10
Merge commit 'afadf502bae42334c571da76910e9ca63d59162e'

Conflicts:
	NEWS.md
@cderv
Copy link
Collaborator

cderv commented Jul 19, 2021

@yihui Just a friendly ping so that it is on your radar to have a quick thoughts and review from you before deciding to merge this. We can discuss it live tomorrow if you have time to have a look. Thanks!

Behavior of this PR is described here: #1035 (comment)

@cderv cderv requested a review from yihui July 19, 2021 13:33
yihui added 4 commits July 19, 2021 16:16
…w R session; they must be passed explicitly as an argument list
…es like `html_head` to build_404(), and build_404() only creates a raw 404 page, which can be tweaked in split_chapters() later
Copy link
Contributor

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cderv Just two small questions. Thanks!

Copy link
Collaborator

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for you changes !

That makes a lot of sense to tweak the function this way. Also existing_files() is a useful function ! 😅 Hard to know them all 😉

I guess you found the idea interesting. That left us with

  • the choice of what should we do with an existing 404.html: should we copy it (#1035 (comment)) in output dir ?
  • We need to document this. Where in the book ? Or in which function's help page ? I can do it once we decide.

@yihui
Copy link
Contributor

yihui commented Jul 20, 2021

For documentation, perhaps we could add a section in Chapter 6: https://bookdown.org/yihui/bookdown/publishing.html This topic seems to be too small to fit a whole section, though.

@cderv
Copy link
Collaborator

cderv commented Jul 21, 2021

For documentation, perhaps we could add a section in Chapter 6

This could indeed be a good place to put it in the Github publishing section as 404.html is supported by it. We don't have a Netlify part yet, but it will also be supported. However, no matter where you publish a 404 page will be created though.

I was thinking maybe into:

Copy link
Contributor

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can discuss the documentation later. This PR looks good to me now.

@cderv
Copy link
Collaborator

cderv commented Jul 21, 2021

I opened a new issue to track the documentation.

And I'll merge this one then.

Thank you !

@cderv cderv merged commit 7203154 into rstudio:master Jul 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

404 page for gitbook? bs4_book: add a default 404 page?

4 participants