[fastpages] GitHub Pages Blog Using Nbdev

@hamelsmu, thank you fro the reply. I was wondering that too. Could we include it in the docs…

1 Like

@hamelsmu For those three commands you just listed: The first two work fine. For the last one, I get…

$ git merge upstream/master
fatal: refusing to merge unrelated histories

This is for my repo created from your “click here” method of forking. What should we do when we get that error?

@drscotthawley try this https://www.educative.io/edpresso/the-fatal-refusing-to-merge-unrelated-histories-git-error

1 Like

Ok @hamelsmu. so

$ git merge upstream/master --allow-unrelated-histories
warning: Cannot merge binary files: favicon.ico (HEAD vs. upstream/master)
Auto-merging index.md
CONFLICT (add/add): Merge conflict in index.md
Auto-merging favicon.ico
CONFLICT (add/add): Merge conflict in favicon.ico
Auto-merging assets/main.scss
CONFLICT (add/add): Merge conflict in assets/main.scss
Auto-merging about.md
CONFLICT (add/add): Merge conflict in about.md
Auto-merging _setup_pr_template.md
CONFLICT (add/add): Merge conflict in _setup_pr_template.md
Auto-merging _layouts/post.html
CONFLICT (add/add): Merge conflict in _layouts/post.html
Auto-merging _layouts/notebook.html
CONFLICT (add/add): Merge conflict in _layouts/notebook.html
Auto-merging _includes/head.html
CONFLICT (add/add): Merge conflict in _includes/head.html
Auto-merging _config.yml
CONFLICT (add/add): Merge conflict in _config.yml
Auto-merging _action_files/settings.ini
CONFLICT (add/add): Merge conflict in _action_files/settings.ini
Auto-merging _action_files/fastpages.tpl
CONFLICT (add/add): Merge conflict in _action_files/fastpages.tpl
Auto-merging _action_files/Dockerfile
CONFLICT (add/add): Merge conflict in _action_files/Dockerfile
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Auto-merging .github/workflows/setup.yaml
CONFLICT (add/add): Merge conflict in .github/workflows/setup.yaml
Auto-merging .github/workflows/ci.yaml
CONFLICT (add/add): Merge conflict in .github/workflows/ci.yaml
Automatic merge failed; fix conflicts and then commit the result.

Whoa… so many conflicts in files I never touched! Not sure if I’m going to succeed at keeping/replacing the right parts, but I’ll get started with vi…
EDIT: Got it all done. Thanks.

My situation is the same as you. I wonder if this is caused by the difference between fork and template.Should we fork instead of creating through templates?

1 Like

The best thing to do right now is to copy your blog posts (notebooks, word, markdown posts) to the a new repo you create from the new template. This is going to offer the easiest path at the moment

If you do significant customizations to your site the upgrade is going to be difficult, not sure there is a solution to that, yet.

3 Likes

Thank! love this tool a lot, it make the blogging experience more seamlessly that I can just write in notebook and commit without worrying how to convert it to markdown later.

One small opinion about the page, it would be great if in the index page it could show more than just the blog title, I am thinking of also showing the summary from the notebook and optionally with images.

Another thing, I would like to change is the style/theme for the code block, I found the dark theme does not look very nice with a white background.

I had tried different Github Pages themes but the rest of the supported ones didn’t work as I expected. It’s probably due to my lack of knowledge in jekyll&co. Also note that I tested them within the original fastpages template.

Changing themes is not supported because there are too many opportunities for CSS collisions. fastpages is a very opinionated platform with the trade off of making it easy for you.

Re: syntax highlighting that is something you can customize via CSS yourself if you so choose but is not something I plan on working on anytime soon. PRs are welcome on this, however.

Edit: you can use your own theme if you have enough knowledge of Jekyll and GitHub Actions, but it requires some work for each person. I think we would take a blog submission for someone who wants to go through this adventure and document their journey!

1 Like

@nok I don’t know about putting picture previews, I’ll leave that up to the user to customize that. I do agree that having a summary under the title is probably necessary.

Added the below feature via https://github.com/fastai/fastpages/pull/95

You will have to copy all of your posts over if you want to upgrade.

1 Like

Thank you. Do I have to recreate from fastpages and copy my notes over? Since the first PR will modify the repo quite a bit, I am not sure how to pull the changes to upgrade

1 Like

Remind me: does fastpages support creating twitter cards for posts? We have that in fast.ai, but I don’t recall if it was copied over to fastpages. (If not, it probably should be, because it’s handy!)

The reason I mention it here is because it uses a special key image in the frontmatter, which could also be used in a post summary I guess.

1 Like

Hi @nok the way I would do it ( we will try to automate this at some point but bear with us):

  • create a new repo from the template
  • merge the PR etc. from the new repo
  • copy all your posts over manually, add, commit and push them to master.

Hope that helps

@jeremy

Yes fastpages has the jekyll-seo-tag plugin (I believe it comes with minima) that supports the image and description front matter. I haven’t tested the image part of it but the description works.

I can add this to my backlog to test and verify that this works

Edit image previews in twitter work via the image: front matter

However, at the moment doesn’t seem to:

  • support remote urls
  • you can only reference images in assets/ or images/
  • this is one of those cumbersome situations if you reference your image locally to the notebooks folder, it will not work.

@jeremy How are you doing it now? Is this the same thing you are doing?

That’s an interesting idea of using twitter card summaries as previews on the home page I haven’t thought of that. I Will look into this!

Embarrassingly, I didn’t know about that plugin, so I added this to the template head layout:

  <meta name="twitter:site"    content="@{{ site.twitter_username }}">
  <meta name="twitter:creator" content="@{{ page.author }}">
  <meta name="twitter:title"   content="{{ page.title }}">
  {% if page.summary %}
  <meta name="twitter:description" content="{{ page.summary }}">
  {% else %}
  <meta name="twitter:description" content="{{ site.description }}">
  {% endif %}
  {% if page.image %}
  <meta name="twitter:card"  content="summary_large_image">
  <meta name="twitter:image" content="{{ site.url }}{{ page.image }}">
  {% else %}
  {% endif %}

Since it uses summary, it works with the usual nbdev summary. Although if description is more common, it’s possible nbdev should set that metadata too…

BTW this is a great tool for testing cards: https://cards-dev.twitter.com/validator

1 Like

I was looking for the card validator for hours! Thank you for sharing that

@jeremy @nok

Good news the image preview on the homepage feature has now been enabled on fastpages via https://github.com/fastai/fastpages/pull/104

Usage

You can enable this option by setting

show_image: true

in /_config.yml , it is set to false by default.

2 Likes

@jeremy BTW I’m doing this in my template to alias the summary in nbdev to description for this exact reason

{% if k == "summary" and "description" not in resources %}description{% else %}{{ k }}{% endif %}: {{ resources[k] |replace(':', '') }} 

Not sure if its too hacky or not. Just sharing. I guess it makes notebooks and markdown behave a bit differently. I will put this on the list of things I have to document for users.

1 Like