Skip to content

Commit

Permalink
Merge branch 'master' into feature/google-analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Jun 15, 2022
2 parents 78301df + 50fc665 commit 83c8b97
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 45 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2017 Yihui Xie
Copyright (c) 2017-2021 Yihui Xie

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
14 changes: 8 additions & 6 deletions exampleSite/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,27 @@ permalinks:
menu:
main:
- name: Home
url: /
url: ""
weight: 1
- name: About
url: /about/
url: "about/"
weight: 2
- name: Categories
url: /categories/
url: "categories/"
weight: 3
- name: Tags
url: /tags/
url: "tags/"
weight: 4
- name: Subscribe
url: /index.xml
url: "index.xml"

params:
description: "A website built through Hugo and blogdown."
footer: "© [Yihui Xie](https://yihui.org) 2017 -- 2020 | [Github](https://github.com/yihui) | [Twitter](https://twitter.com/xieyihui)"
footer: "© [Yihui Xie](https://yihui.org) 2017 -- {Year} | [Github](https://github.com/yihui) | [Twitter](https://twitter.com/xieyihui)"

markup:
highlight:
codeFences: false
goldmark:
renderer:
unsafe: true
2 changes: 1 addition & 1 deletion exampleSite/content/_index.Rmarkdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ title: Home

**XMin** is a Hugo theme written by [Yihui Xie](https://yihui.org) in about four hours: half an hour was spent on the Hugo templates, and 3.5 hours were spent on styling. The main motivation for writing this theme was to provide a really minimal example to beginners of Hugo templates. This XMin theme contains about 130 lines of code in total, including the code in HTML templates and CSS (also counting empty lines).

```{bash, comment='', echo=3, eval=Sys.which('bash') != ''}
```{bash, comment='', echo=3, eval=Sys.which('bash') != '', message=FALSE}
cd ../..;
if [ ! -f 'theme.toml' ]; then exit 0; fi # only run find below within the theme example site
find . -not -path '*/exampleSite/*' \( -name '*.html' -o -name '*.css' \) | xargs wc -l
Expand Down
57 changes: 27 additions & 30 deletions exampleSite/content/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,56 @@ author: Yihui Xie

The theme name "XMin" can be interpreted as "**X**ie's **Min**imal theme" (Xie is my last name) or "e**X**tremely **Min**imal theme".

# config.toml
# config.yaml

For this example site, I defined permalinks for two sections, `post` and `note`, so that the links to pages under these directories will contain the date info, e.g., `https://xmin.yihui.org/post/2016/02/14/a-plain-markdown-post/`. This is optional, and it is up to your personal taste of URLs.

```
[permalinks]
post = "/post/:year/:month/:day/:slug/"
note = "/note/:year/:month/:day/:slug/"
```yaml
permalinks:
note: "/note/:year/:month/:day/:slug/"
post: "/post/:year/:month/:day/:slug/"
```
You can define the menu through `menu.main`, e.g.,

```
[[menu.main]]
name = "Home"
url = "/"
weight = 1
[[menu.main]]
name = "About"
url = "/about/"
weight = 2
[[menu.main]]
name = "Categories"
url = "/categories/"
weight = 3
[[menu.main]]
name = "Tags"
url = "/tags/"
weight = 4
[[menu.main]]
name = "Subscribe"
url = "/index.xml"
```yaml
menu:
main:
- name: Home
url: ""
weight: 1
- name: About
url: "about/"
weight: 2
- name: Categories
url: "categories/"
weight: 3
- name: Tags
url: "tags/"
weight: 4
- name: Subscribe
url: "index.xml"
```

Alternatively, you can add `menu: main` to the YAML metadata of any of your pages, so that these pages will appear in the menu.

The page footer can be defined in `.Params.footer`, and the text is treated as Markdown, e.g.,

```
[params]
footer = "© [Yihui Xie](https://yihui.org) 2017"
params:
footer: "© [Yihui Xie](https://yihui.org) 2017 -- 2021"
```
# Custom layouts
There are two layout files under `layouts/partials/` that you may want to override: `head_custom.html` and `foot_custom.html`. This is how you inject arbitrary HTML code to the head and foot areas. For example, this site has a file `layouts/partials/foot_custom.html` to support LaTeX math via MathJax and center images automatically:
```html
<script src="//yihui.org/js/math-code.js"></script>
<script async src="//cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
<script defer src="//yihui.org/js/math-code.js"></script>
<script defer src="//cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<script async src="//yihui.org/js/center-img.js"></script>
<script defer src="//yihui.org/js/center-img.js"></script>
```

You can certainly enable highlight.js for syntax highlighting by yourself through `head_custom.html` and `foot_custom.html` if you want.
Expand Down
4 changes: 2 additions & 2 deletions exampleSite/content/note/2017-06-14-another-note.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ tags:
slug: another-note
---

I just discovered [an awesome tutorial](https://apreshill.rbind.io/post/up-and-running-with-blogdown/) on **blogdown** written by Alison. I have to admit this is _the_ best **blogdown** tutorial I have seen so far.
I just discovered [an awesome tutorial](https://www.apreshill.com/blog/2020-12-new-year-new-blogdown/) on **blogdown** written by Alison. I have to admit this is _the_ best **blogdown** tutorial I have seen so far.

![](https://apreshill.rbind.io/img/posts/2017-06-12-up-and-running-with-blogdown/blogdown-signpost-4.png)
![Alison's blogdown tutorial](https://www.apreshill.com/blog/2020-12-new-year-new-blogdown/03-blogdown-2021.png)
6 changes: 3 additions & 3 deletions exampleSite/layouts/partials/foot_custom.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script src="//yihui.org/js/math-code.js"></script>
<script async src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script defer src="//yihui.org/js/math-code.js"></script>
<script defer src="//mathjax.rstudio.com/latest/MathJax.js?config=TeX-MML-AM_CHTML"></script>

<script async src="//yihui.org/js/center-img.js"></script>
<script defer src="//yihui.org/js/center-img.js"></script>

{{ template "_internal/google_analytics.html" . }}
2 changes: 1 addition & 1 deletion layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ partial "foot_custom.html" . }}
{{ with .Site.Params.footer }}
<hr/>
{{ . | markdownify }}
{{ replace . "{Year}" now.Year | markdownify}}
{{ end }}
</footer>
</body>
Expand Down
2 changes: 1 addition & 1 deletion static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ body {
max-width: 800px;
margin: auto;
padding: 1em;
line-height: 1.5em;
line-height: 1.5;
}

/* header and footer areas */
Expand Down

0 comments on commit 83c8b97

Please sign in to comment.