From e06a0625c89e49dff87c3deb1be95776c5d8cb19 Mon Sep 17 00:00:00 2001 From: statnmap Date: Sat, 29 Dec 2018 22:27:08 +0100 Subject: [PATCH] Citation: new field in each post --- README.Rmd | 376 +++++++++++++++++++++++++++++++ README.md | 401 +++++++++++++++------------------ exampleSite/config.toml | 4 + i18n/en.toml | 7 + i18n/fr.toml | 7 + layouts/partials/citation.html | 29 +++ layouts/partials/single.html | 1 + 7 files changed, 608 insertions(+), 217 deletions(-) create mode 100644 README.Rmd create mode 100644 layouts/partials/citation.html diff --git a/README.Rmd b/README.Rmd new file mode 100644 index 0000000..08a5444 --- /dev/null +++ b/README.Rmd @@ -0,0 +1,376 @@ +--- +output: github_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +# StatnMap Hugo theme + +StatnMap theme is issued from [hugo-icarus-theme by digitalcraftsman](https://github.com/digitalcraftsman/hugo-icarus-theme), but I thought visual changes were to big to keep it as a fork. This is a responsive and customizable theme for bloggers and freelancers. It's originally a port of the Icarus theme for [Hexo](//hexo.io) made by [Ruipeng Zhang](https://github.com/ppoffice). The theme has been revamped to look like wordpress twenty-fifteen theme. +Noteworthy features of this Hugo theme are the integration of a comment-system powered by **Disqus**, **multilingual** support and **language switch**, **syntax highlighting** and **code folding** for source code, **how-to-cite card** and **related articles** sections on bottom of articles, **contact form** and optional widgets for the sidebar. + +![](https://github.com/statnmap/hugo-statnmap-theme/blob/master/images/screenshot.png) + + +You can see a live example here: + +## Table of Contents + + + +- [Table of Contents](#table-of-contents) +- [Get the theme](#get-the-theme) +- [Setup](#setup) + - [Comments](#comments) + - [Menu](#menu) + - [Sidebars](#sidebars) + - [Tell me who you are](#tell-me-who-you-are) + - [Widgets](#widgets) + - [Date line](#date-line) +- [Multilanguage](#multilingual) +- [Contact form](#contact-form) +- [Linking thumbnails](#linking-thumbnails) +- [Mathematical equations](#mathematical-equations) +- [Syntax highlighting](#syntax-highlighting) +- [Code Folding](#code-folding) +- [Sticky list pages](#sticky-list-pages) +- [Gallery shortcode](#gallery-shortcode) +- [Citation card](#citation) +- [Related articles](#related-articles) +- [Website SEO](#website-seo) +- [Nearly finished](#nearly-finished) +- [Contributing](#contributing) +- [License](#license) +- [Acknowledgements](#acknowledgements) + + +## Get the theme + +I assume you've Git installed. Inside the folder of your Hugo site run + + $ cd themes + $ git clone https://github.com/statnmap/hugo-statnmap-theme.git + +You should see a folder called `hugo-statnmap-theme` inside the `themes` directory that we created a few moments ago. For more information read the official [setup guide](https://gohugo.io/overview/installing/) of Hugo. + + +## Setup + +Next, navigate to the `exampleSite` folder at `themes/hugo-type-theme/exampleSite/`. In order to get your site running, you need to copy `config.toml` and all the content of all relevant subfolders such as `i18n/en.toml` into the root folders. + +To turn the `exampleSite` folder in a standalone demo site the `themesDir` property has been set to `../..`. This way you can preview this theme by running `hugo server` inside `exampleSite` folder. + +**Due to the customized `themesDir` path Hugo will fail to find themes if you copied the `config.toml` into the root directory of a regular Hugo website.** Make sure you comment out the `themesDir` property if you use the theme in production. + + +## The config file + +Now, let us take a look into the `config.toml`. Feel free to play around with the settings. + + +### Comments + +The optional comment system is powered by Disqus. Enter your shortname to enable the comment section under your posts. + + disqusShortname = "" + +Tip: you can disable the comment section for a single page in its frontmatter: + +```toml ++++ +disable_comments = true ++++ +``` + + +### Menu + +You can also define the items menu entries as you like. First, let us link a post that you've written. We can do this in the frontmatter of the post's content file by setting `menu` to `main`. + + +++ + menu = "main" + +++ + +Furthermore, we can add entries that don't link to posts. Back in the `config.toml` you'll find a section for the menus: + + [[params.menu]] + before = true + label = "Home" + link = "/" + +Define a label and enter the URL to resource you want to link. With `before` you can decide whether the link should appear before **or** after all linked posts in the menu. Therefore, `Home` appears before the linked post. + + +### Sidebars + +In order to use the full width of the website you can disable the profile on the left and / or the widgets on the right for a single page in the frontmatter: + +```toml ++++ +disable_profile = true +disable_widgets = true ++++ +``` + + +### Tell me who you are + +This theme also provides a profile section on the left. Add your social network accounts to the profile section on the left by entering your username under `social`. The links to your account will be create automatically. + + +### Widgets + +Beside the profile section you can add widgets on the right sidebar. The following widgets are available: + +- recent articles +- category list +- tag list +- tag cloud + +You can deactivate them under `params.widgets`: + + [params.widgets] + recent_articles = false + categories = true + tags = true + tag_cloud = true + +### Date line + +The date line includes: post date, # of words, approximate reading, time tags and categories. However, if you want certain pages to omit the date line, simply put `nodateline = true` in the front matter for that page. + +### Disable Previous / next article links + +To disable the inclusion of a previous/next article link at the bottom of the page, add `noprevnext = true` to the front matter. This feature, along with `nodateline` can be used to create standalone pages that are less "blog-like" + +## Multilingual + +You don't blog in English and you want to translate the theme into different language? No problem. Take a look in the `i18n` folder and you'll find a file `en.toml`. It contains all strings related to the theme. Copy this file, change the name so that it reflects the translation language (like `fr.toml`) and modify the strings needed. + +A language switcher is also available with multilingual website activated. You can add png images of flags named 'lang.png' in 'static/flags' folder, for new languages other than English and French. + +The `config.toml` file in `exampleSite` proposes menus for a second language (French). However, as no posts, itemized or contacts are saved with `.fr.md` extension in this exampleSite, menu items may redirect to the `404 not found` page. + +If you only have one language for your website, you can remove every `Languages`, `Languages.en` and `Languages.fr` occurrences. Simple `[menu.main]` have to be used instead. + +Credit: [statnmap] + +## Contact form + +Since this page will be static, you can use formspree.io as proxy to send the actual email. Each month, visitors can send you up to one thousand emails without incurring extra charges. Begin the setup by following the steps below: + +1. Enter your email address under ‘emailservice’ in contact/index.md file +2. Upload the generated site to your server +3. Send a dummy email yourself to confirm your account +4. Click the confirm link in the email from formspree.io +5. You’re done. Happy mailing! + +Credit: [statnmap] + +## Linking thumbnails + +After creating a new post you can define a banner by entering the relative path to the image. + + banner = "banners/placeholder.png" + +Credit: [digitalcraftsman] + +A thumbnail will be used for the recent_articles list in the sidebar as well as in the normal list of articles. If you want a specific thumbnail instead of the banner croped, you can define it by entering the relative path to the thumbnail. + + thumbnail = "banners/thumbnail.png" + +This way you can store them either next to the content file or in the `static` folder. + +Credit: [statnmap] + +## Mathematical equations + +Mathematical equations in form of LaTeX or MathML code can be rendered with the support of [MathJax](https://www.mathjax.org). MathML works out of the box. If you're using LaTeX you need to wrap your equation with `$$`. + +You can also print formulas inline. In this case wrap the formula only once with `$`. + +If you don't need equations, you can disable MathJax but putting `disable_mathjax = true` in your config.toml. This will prevent clients from unnecessarily downloading the MathJax library. + +MathJax CDN and versions can be modified in the `config.toml` file: + + MathJaxCDN = "//cdn.bootcss.com" + MathJaxVersion = "2.7.1" + +## Syntax highlighting + +Syntax highlighting for code is allowed with `highlight.js`. This can be disabled in the `config.toml`. Version, additional languages, CDN and theme can also be modified. + + disable_highlight = false + highlightjsVersion = "9.11.0" + highlightjsCDN = "//cdn.bootcss.com" + highlightjsLang = ["r", "yaml"] + highlightjsTheme = "github" + +Credit: [yihui] [statnmap] + +## Code folding +Code folding is enabled by default with `disable_codefolding = false` in parameters of the `config` file. It uses somes javascript libraries of [bootstrap](https://getbootstrap.com/docs/3.3/javascript/). Code folding (multilingual) buttons only appear when there is code in the document rendered from `Rmd` in blogdown. `disable_codefolding` can also be used in each article config header. Similarly, you can define if code blocks are shown or hidden by default using `codefolding_show = "hide"` in the config file or in each article config. +The list of `
` blocks on which to apply code folding is defined in the `config` file: 
+`codeblocks = ["pre.sourceCode", "pre.r", "pre.python"]`
+
+Credit: [statnmap]
+
+## Sticky list pages
+
+A special kind of posts list is implemented. This allows to show the first article completely and the other articles as a list with summaries. For that, we use the implemented template `list_first_plain_sticky.html` in `partial`. You can use it in two ways:  
+
+1. With Taxonomy
+This is implemented in the `exampleSite`.
+    + Create a new taxonomy like 'sticky':
+    
+    ```
+    [Taxonomies]
+      tag = "tags"
+      category = "categories"
+      sticky = "stickies"
+    ```
+    + Create a folder `layout` > `taxonomy`
+    + Create a html file named `sticky.html` with this code:
+    
+    ```
+    {{ define "main" }}
+      {{ if isset .Site.Taxonomies "sticky" }}
+        {{ partial "list_first_plain_sticky" . }}
+      {{ end }}
+    {{ end }}
+    ```
+  
+    + Add taxonomy `stickies` in a post or a page. The newest page or the page with `weight = 1` will be shown entirely before the other of the same taxonomy (that will only show a summary). In the exampleSite, pages in `sticky_pages` have this taxonomy.
+
+
+2. With special pages
+
+    + Create a folder `layout` > `sticky_pages` for instance
+    + Create a html file named `list.html` with this code:
+    
+    ```
+    {{ define "main" }}
+        {{ partial "list_first_plain_sticky" . }}
+    {{ end }}
+    ```
+
+    + Create a folder `content` > `sticky_pages` (This is done in the `exampleSite`)
+    + Add a page. The newest page or the page with `weight = 1` will be shown entirely before the other of the same taxonomy (that will only show a summary)
+
+Credit: [statnmap]
+
+## Citation
+
+As for [Radix](https://rstudio.github.io/radix/), a citation field can be added to blog posts. Citation is enabled by default with `disable_citation = false` in parameters of the `config` file. It can also be enabled or disabled in each blog post with `disable_citation` in the post YAML / TOML. By default author comes from blog `author` field in the article header but `citation_author` overrides this field if another writing is needed. `citation_author` can be specified globally in `config` file but also for each blog post.  
+Code is adapted from: Yihan Wu. (2018-12-21). "Blogdown - shortcode for radix-like Bibtex". Retrieved from https://www.yihanwu.ca/post/blogdown-shortcode-generation-for-bibtex/.
+
+Credit: [statnmap]
+
+## Gallery shortcode
+
+This shortcode you to easily include a gallery into your pages. Copy the code below into your content file and enter the relative paths to your images.
+
+    {{< gallery
+        "/banners/placeholder.png"
+        "/banners/placeholder.png"
+        "/banners/placeholder.png"
+    >}}
+
+
+## Related articles
+
+You can define parameters for related articles at the bottom of blog posts.
+
+```
+[related]
+  # Only include matches with rank >= threshold. This is a normalized rank between 0 and 100.
+  threshold = 50
+  # To get stable "See also" sections we, by default, exclude newer related pages.
+  includeNewer = true
+  # Will lower case keywords in both queries and in the indexes.
+  toLower = true
+[[related.indices]]
+name = "keywords"
+weight = 150
+[[related.indices]]
+name  = "author"
+toLower = true
+weight = 30
+[[related.indices]]
+name  = "tags"
+weight = 100
+[[related.indices]]
+name  = "date"
+weight = 10
+pattern = "2006"
+```
+
+See  for more informations.
+
+Credit: [statnmap]
+
+## Website SEO
+
+This theme support SEO elements for your website.
+It was adapted and integrated thanks to the following guide:  
+[https://keithpblog.org/post/hugo-website-seo/](https://keithpblog.org/post/hugo-website-seo/)
+
+If you wish to enable SEO on this theme, follow these instructions:
+1. To include the following parameters in your _config.toml_ or _config.yaml_
+```
+# .config.toml
+...
+googleAnalytics = "UA-XXXXX-01"
+enableRobotsTXT = true
+canonifyURLs = true
+# and if you think your md file names or locations might change:
+[permalinks]
+    post = "/blog/:title/"
+...
+```
+
+2. Add your website to Google Search Console:
+    - Login to the [Google Search Console](https://www.google.com/webmasters/tools/home)
+    - Add your website as property
+    - Add the html page as required by google to verify ownership
+    - Submit the sitemap (/sitemap.xml) for indexing
+    - Wait
+
+3. Add your website to Bing 
+    - Login to the [Bing Webmaster Console](https://www.bing.com/toolbox/webmaster/)
+    - Add your site, details and verify
+    - From the 3 option, we recommend adding the xml file to you website
+
+## Nearly finished
+
+In order to see your site in action, run Hugo's built-in local server.
+
+    $ hugo server
+
+Now enter [`localhost:4321`](http://localhost:4321) in the address bar of your browser.
+
+
+## Contributing
+
+Have you found a bug or got an idea for a new feature? Feel free to use the [issue tracker](//github.com/statnmap/hugo-statnmap-theme/issues) to let me know. Or make directly a [pull request](//github.com/statnmap/hugo-statnmap-theme/pulls).
+
+
+## License
+
+This theme is released under the MIT license. For more information read the [license](https://github.com/digitalcraftsman/hugo-icarus-theme/blob/master/LICENSE.md).
+
+
+## Acknowledgements
+
+Thanks to 
+
+- [Digitalcraftsman](//github.com/digitalcraftsman/hugo-icarus-theme) for the original Hugo-icarus-theme
+- [Ruipeng Zhang](//github.com/ppoffice) for creating this theme
+- [Steve Francia](//github.com/spf13) for creating Hugo and the awesome community around the project
+
+
+[digitalcraftsman]: //github.com/digitalcraftsman
+[statnmap]: https://github.com/statnmap
+[yihui]: https//github.com/yihui
diff --git a/README.md b/README.md
index 7dd536a..9ee213d 100644
--- a/README.md
+++ b/README.md
@@ -1,43 +1,45 @@
-# StatnMap theme
 
-StatnMap theme is issued from [hugo-icarus-theme from digitalcraftsman](https://github.com/digitalcraftsman/hugo-icarus-theme), but I thought visual changes were to big to keep it as a fork. This is a responsive and customizable theme for bloggers and freelancers. It's originally a port of the Icarus theme for [Hexo](//hexo.io) made by [Ruipeng Zhang](https://github.com/ppoffice). The theme has been revamped to look like wordpress twenty-fifteen theme.  
-Noteworthy features of this Hugo theme are the integration of a comment-system powered by **Disqus**, **localization (i18n)** support and **language switch**, **syntax highlighting** for source code, **contact formular** and optional widgets for the sidebar.
+StatnMap Hugo theme
+===================
+
+StatnMap theme is issued from [hugo-icarus-theme by digitalcraftsman](https://github.com/digitalcraftsman/hugo-icarus-theme), but I thought visual changes were to big to keep it as a fork. This is a responsive and customizable theme for bloggers and freelancers. It's originally a port of the Icarus theme for [Hexo](//hexo.io) made by [Ruipeng Zhang](https://github.com/ppoffice). The theme has been revamped to look like wordpress twenty-fifteen theme.
+Noteworthy features of this Hugo theme are the integration of a comment-system powered by **Disqus**, **multilingual** support and **language switch**, **syntax highlighting** and **code folding** for source code, **how-to-cite card** and **related articles** sections on bottom of articles, **contact form** and optional widgets for the sidebar.
 
 ![](https://github.com/statnmap/hugo-statnmap-theme/blob/master/images/screenshot.png)
 
+You can see a live example here: 
 
-## Table of Contents
+Table of Contents
+-----------------
 
 
-
-- [Table of Contents](#table-of-contents)
-- [Get the theme](#get-the-theme)
-- [Setup](#setup)
-	- [Comments](#comments)
-	- [Menu](#menu)
-	- [Sidebars](#sidebars)
-	- [Tell me who you are](#tell-me-who-you-are)
-	- [Widgets](#widgets)
-	- [Date line](#date-line)
-- [Multilanguage](#multilingual)
-- [Contact form](#contact-form)
-- [Linking thumbnails](#linking-thumbnails)
-- [Mathematical equations](#mathematical-equations)
-- [Syntax highlighting](#syntax-highlighting)
-- [Code Folding](#code-folding)
-- [Sticky list pages](#sticky-list-pages)
-- [Related articles](#related-articles)
-- [Gallery shortcode](#gallery-shortcode)
-- [Citation](#citation)
-- [Related articles](#related-articles)
-- [Website SEO](#website-seo)
-- [Nearly finished](#nearly-finished)
-- [Contributing](#contributing)
-- [License](#license)
-- [Acknowledgements](#acknowledgements)
-
-
-## Get the theme
+-   [Table of Contents](#table-of-contents)
+-   [Get the theme](#get-the-theme)
+-   [Setup](#setup)
+    -   [Comments](#comments)
+    -   [Menu](#menu)
+    -   [Sidebars](#sidebars)
+    -   [Tell me who you are](#tell-me-who-you-are)
+    -   [Widgets](#widgets)
+    -   [Date line](#date-line)
+-   [Multilanguage](#multilingual)
+-   [Contact form](#contact-form)
+-   [Linking thumbnails](#linking-thumbnails)
+-   [Mathematical equations](#mathematical-equations)
+-   [Syntax highlighting](#syntax-highlighting)
+-   [Code Folding](#code-folding)
+-   [Sticky list pages](#sticky-list-pages)
+-   [Gallery shortcode](#gallery-shortcode)
+-   [Citation card](#citation)
+-   [Related articles](#related-articles)
+-   [Website SEO](#website-seo)
+-   [Nearly finished](#nearly-finished)
+-   [Contributing](#contributing)
+-   [License](#license)
+-   [Acknowledgements](#acknowledgements)
+
+Get the theme
+-------------
 
 I assume you've Git installed. Inside the folder of your Hugo site run
 
@@ -46,21 +48,20 @@ I assume you've Git installed. Inside the folder of your Hugo site run
 
 You should see a folder called `hugo-statnmap-theme` inside the `themes` directory that we created a few moments ago. For more information read the official [setup guide](https://gohugo.io/overview/installing/) of Hugo.
 
+Setup
+-----
 
-## Setup
-
-Next, navigate to the `exampleSite` folder at `themes/hugo-type-theme/exampleSite/`.  In order to get your site running, you need to copy `config.toml` and all the content of all relevant subfolders such as `i18n/en.toml` into the root folders.
+Next, navigate to the `exampleSite` folder at `themes/hugo-type-theme/exampleSite/`. In order to get your site running, you need to copy `config.toml` and all the content of all relevant subfolders such as `i18n/en.toml` into the root folders.
 
 To turn the `exampleSite` folder in a standalone demo site the `themesDir` property has been set to `../..`. This way you can preview this theme by running `hugo server` inside `exampleSite` folder.
 
 **Due to the customized `themesDir` path Hugo will fail to find themes if you copied the `config.toml` into the root directory of a regular Hugo website.** Make sure you comment out the `themesDir` property if you use the theme in production.
 
-
-## The config file
+The config file
+---------------
 
 Now, let us take a look into the `config.toml`. Feel free to play around with the settings.
 
-
 ### Comments
 
 The optional comment system is powered by Disqus. Enter your shortname to enable the comment section under your posts.
@@ -69,13 +70,12 @@ The optional comment system is powered by Disqus. Enter your shortname to enable
 
 Tip: you can disable the comment section for a single page in its frontmatter:
 
-```toml
+``` toml
 +++
 disable_comments = true
 +++
 ```
 
-
 ### Menu
 
 You can also define the items menu entries as you like. First, let us link a post that you've written. We can do this in the frontmatter of the post's content file by setting `menu` to `main`.
@@ -93,32 +93,29 @@ Furthermore, we can add entries that don't link to posts. Back in the `config.to
 
 Define a label and enter the URL to resource you want to link. With `before` you can decide whether the link should appear before **or** after all linked posts in the menu. Therefore, `Home` appears before the linked post.
 
-
 ### Sidebars
 
 In order to use the full width of the website you can disable the profile on the left and / or the widgets on the right for a single page in the frontmatter:
 
-```toml
+``` toml
 +++
 disable_profile = true
 disable_widgets = true
 +++
 ```
 
-
 ### Tell me who you are
 
 This theme also provides a profile section on the left. Add your social network accounts to the profile section on the left by entering your username under `social`. The links to your account will be create automatically.
 
-
 ### Widgets
 
 Beside the profile section you can add widgets on the right sidebar. The following widgets are available:
 
-- recent articles
-- category list
-- tag list
-- tag cloud
+-   recent articles
+-   category list
+-   tag list
+-   tag cloud
 
 You can deactivate them under `params.widgets`:
 
@@ -130,15 +127,16 @@ You can deactivate them under `params.widgets`:
 
 ### Date line
 
-The date line includes: post date, # of words, approximate reading, time tags and categories. However, if you want certain pages to omit the date line, simply put `nodateline = true` in the front matter for that page.
+The date line includes: post date, \# of words, approximate reading, time tags and categories. However, if you want certain pages to omit the date line, simply put `nodateline = true` in the front matter for that page.
 
 ### Disable Previous / next article links
 
 To disable the inclusion of a previous/next article link at the bottom of the page, add `noprevnext = true` to the front matter. This feature, along with `nodateline` can be used to create standalone pages that are less "blog-like"
 
-## Multilingual
+Multilingual
+------------
 
-You don't blog in English and you want to translate the theme into different language? No problem. Take a look in the `i18n` folder and you'll find a file `en.toml` that we've copied at the beginning. It contains all strings related to the theme. Copy this file, change the name so that it reflects the translation language (like `fr.toml`) and modify the strings needed.
+You don't blog in English and you want to translate the theme into different language? No problem. Take a look in the `i18n` folder and you'll find a file `en.toml`. It contains all strings related to the theme. Copy this file, change the name so that it reflects the translation language (like `fr.toml`) and modify the strings needed.
 
 A language switcher is also available with multilingual website activated. You can add png images of flags named 'lang.png' in 'static/flags' folder, for new languages other than English and French.
 
@@ -146,37 +144,40 @@ The `config.toml` file in `exampleSite` proposes menus for a second language (Fr
 
 If you only have one language for your website, you can remove every `Languages`, `Languages.en` and `Languages.fr` occurrences. Simple `[menu.main]` have to be used instead.
 
-Credit: [statnmap]
+Credit: [statnmap](https://github.com/statnmap)
 
-## Contact form
+Contact form
+------------
 
 Since this page will be static, you can use formspree.io as proxy to send the actual email. Each month, visitors can send you up to one thousand emails without incurring extra charges. Begin the setup by following the steps below:
 
-1. Enter your email address under ‘emailservice’ in contact/index.md file
-2. Upload the generated site to your server
-3. Send a dummy email yourself to confirm your account
-4. Click the confirm link in the email from formspree.io
-5. You’re done. Happy mailing!
+1.  Enter your email address under ‘emailservice’ in contact/index.md file
+2.  Upload the generated site to your server
+3.  Send a dummy email yourself to confirm your account
+4.  Click the confirm link in the email from formspree.io
+5.  You’re done. Happy mailing!
 
-Credit: [statnmap]
+Credit: [statnmap](https://github.com/statnmap)
 
-## Linking thumbnails
+Linking thumbnails
+------------------
 
 After creating a new post you can define a banner by entering the relative path to the image.
 
     banner = "banners/placeholder.png"
 
-Credit: [digitalcraftsman]
+Credit: [digitalcraftsman](//github.com/digitalcraftsman)
 
-A thumbnail will be used for the recent_articles list in the sidebar as well as in the normal list of articles. If you want a specific thumbnail instead of the banner croped, you can define it by entering the relative path to the thumbnail.
+A thumbnail will be used for the recent\_articles list in the sidebar as well as in the normal list of articles. If you want a specific thumbnail instead of the banner croped, you can define it by entering the relative path to the thumbnail.
 
     thumbnail = "banners/thumbnail.png"
 
 This way you can store them either next to the content file or in the `static` folder.
 
-Credit: [statnmap]
+Credit: [statnmap](https://github.com/statnmap)
 
-## Mathematical equations
+Mathematical equations
+----------------------
 
 Mathematical equations in form of LaTeX or MathML code can be rendered with the support of [MathJax](https://www.mathjax.org). MathML works out of the box. If you're using LaTeX you need to wrap your equation with `$$`.
 
@@ -189,7 +190,8 @@ MathJax CDN and versions can be modified in the `config.toml` file:
     MathJaxCDN = "//cdn.bootcss.com"
     MathJaxVersion = "2.7.1"
 
-## Syntax highlighting
+Syntax highlighting
+-------------------
 
 Syntax highlighting for code is allowed with `highlight.js`. This can be disabled in the `config.toml`. Version, additional languages, CDN and theme can also be modified.
 
@@ -199,97 +201,70 @@ Syntax highlighting for code is allowed with `highlight.js`. This can be disable
     highlightjsLang = ["r", "yaml"]
     highlightjsTheme = "github"
 
-Credit: [yihui] [statnmap]
-
-## Code folding
-Code folding is enabled by default with `disable_codefolding = false` in parameters of the `config` file. It uses somes javascript libraries of [bootstrap](https://getbootstrap.com/docs/3.3/javascript/). Code folding (multilingual) buttons only appear when there is code in the document rendered from `Rmd` in blogdown. `disable_codefolding` can also be used in each article config header. Similarly, you can define if code blocks are shown or hidden by default using `codefolding_show = "hide"` in the config file or in each article config.  
-The list of `
` blocks on which to apply code folding is defined in the `config` file: 
-`codeblocks = ["pre.sourceCode", "pre.r", "pre.python"]`
-
-Credit: [statnmap]
-
-## Sticky list pages
-
-A special kind of posts list is implemented. This allows to show the first article completely and the other articles as a list with summaries. For that, we use the implemented template `list_first_plain_sticky.html` in `partial`. You can use it in two ways:  
-
-1. With Taxonomy
-This is implemented in the `exampleSite`.
-    + Create a new taxonomy like 'sticky':
-    
-    ```
-    [Taxonomies]
-      tag = "tags"
-      category = "categories"
-      sticky = "stickies"
-    ```
-    + Create a folder `layout` > `taxonomy`
-    + Create a html file named `sticky.html` with this code:
-    
-    ```
-    {{ define "main" }}
-      {{ if isset .Site.Taxonomies "sticky" }}
-        {{ partial "list_first_plain_sticky" . }}
-      {{ end }}
-    {{ end }}
-    ```
-  
-    + Add taxonomy `stickies` in a post or a page. The newest page or the page with `weight = 1` will be shown entirely before the other of the same taxonomy (that will only show a summary). In the exampleSite, pages in `sticky_pages` have this taxonomy.
-
-
-2. With special pages
-
-    + Create a folder `layout` > `sticky_pages` for instance
-    + Create a html file named `list.html` with this code:
-    
-    ```
-    {{ define "main" }}
-        {{ partial "list_first_plain_sticky" . }}
-    {{ end }}
-    ```
-
-    + Create a folder `content` > `sticky_pages` (This is done in the `exampleSite`)
-    + Add a page. The newest page or the page with `weight = 1` will be shown entirely before the other of the same taxonomy (that will only show a summary)
-
-Credit: [statnmap]
-
-## Related articles
+Credit: [yihui](https://github.com/statnmap)
 
-You can define parameters for related articles at the bottom of blog posts.
+Code folding
+------------
 
-[related]
-  # Only include matches with rank >= threshold. This is a normalized rank between 0 and 100.
-  threshold = 50
-  # To get stable "See also" sections we, by default, exclude newer related pages.
-  includeNewer = true
-  # Will lower case keywords in both queries and in the indexes.
-  toLower = true
-[[related.indices]]
-name = "keywords"
-weight = 150
-[[related.indices]]
-name  = "author"
-toLower = true
-weight = 30
-[[related.indices]]
-name  = "tags"
-weight = 100
-[[related.indices]]
-name  = "date"
-weight = 10
-pattern = "2006"
+Code folding is enabled by default with `disable_codefolding = false` in parameters of the `config` file. It uses somes javascript libraries of [bootstrap](https://getbootstrap.com/docs/3.3/javascript/). Code folding (multilingual) buttons only appear when there is code in the document rendered from `Rmd` in blogdown. `disable_codefolding` can also be used in each article config header. Similarly, you can define if code blocks are shown or hidden by default using `codefolding_show = "hide"` in the config file or in each article config.
+The list of `
` blocks on which to apply code folding is defined in the `config` file: `codeblocks = ["pre.sourceCode", "pre.r", "pre.python"]`
 
-See  for more informations.
+Credit: [statnmap](https://github.com/statnmap)
+
+Sticky list pages
+-----------------
+
+A special kind of posts list is implemented. This allows to show the first article completely and the other articles as a list with summaries. For that, we use the implemented template `list_first_plain_sticky.html` in `partial`. You can use it in two ways:
+
+1.  With Taxonomy This is implemented in the `exampleSite`.
+    -   Create a new taxonomy like 'sticky':
+
+    
+
+        [Taxonomies]
+          tag = "tags"
+          category = "categories"
+          sticky = "stickies"
+
+    -   Create a folder `layout` > `taxonomy`
+    -   Create a html file named `sticky.html` with this code:
+
+    
 
-Credit: [statnmap]
+        {{ define "main" }}
+          {{ if isset .Site.Taxonomies "sticky" }}
+            {{ partial "list_first_plain_sticky" . }}
+          {{ end }}
+        {{ end }}
 
-## Citation
+    -   Add taxonomy `stickies` in a post or a page. The newest page or the page with `weight = 1` will be shown entirely before the other of the same taxonomy (that will only show a summary). In the exampleSite, pages in `sticky_pages` have this taxonomy.
 
-As for [Radix](https://rstudio.github.io/radix/), a citation field can be added to blog posts. Citation is enabled by default with `disable_citation = false` in parameters of the `config` file. It can also be enabled or disabled in each blog post with `disable_citation` in the post YAML / TOML. By default author comes from blog `author` field in the article header but `citation_author` overrides this field if another writing is needed.
-Code is adapted from: Yihan Wu. (2018-12-21). "Blogdown - shortcode for radix-like Bibtex". Retrieved from https://www.yihanwu.ca/post/blogdown-shortcode-generation-for-bibtex/.
+2.  With special pages
 
-Credit: [statnmap]
+    -   Create a folder `layout` > `sticky_pages` for instance
+    -   Create a html file named `list.html` with this code:
 
-## Gallery shortcode
+    
+
+        {{ define "main" }}
+            {{ partial "list_first_plain_sticky" . }}
+        {{ end }}
+
+    -   Create a folder `content` > `sticky_pages` (This is done in the `exampleSite`)
+    -   Add a page. The newest page or the page with `weight = 1` will be shown entirely before the other of the same taxonomy (that will only show a summary)
+
+Credit: [statnmap](https://github.com/statnmap)
+
+Citation
+--------
+
+As for [Radix](https://rstudio.github.io/radix/), a citation field can be added to blog posts. Citation is enabled by default with `disable_citation = false` in parameters of the `config` file. It can also be enabled or disabled in each blog post with `disable_citation` in the post YAML / TOML. By default author comes from blog `author` field in the article header but `citation_author` overrides this field if another writing is needed. `citation_author` can be specified globally in `config` file but also for each blog post.
+Code is adapted from: Yihan Wu. (2018-12-21). "Blogdown - shortcode for radix-like Bibtex". Retrieved from .
+
+Credit: [statnmap](https://github.com/statnmap)
+
+Gallery shortcode
+-----------------
 
 This shortcode you to easily include a gallery into your pages. Copy the code below into your content file and enter the relative paths to your images.
 
@@ -299,71 +274,68 @@ This shortcode you to easily include a gallery into your pages. Copy the code be
         "/banners/placeholder.png"
     >}}
 
-
-## Related articles
+Related articles
+----------------
 
 You can define parameters for related articles at the bottom of blog posts.
 
-```
-[related]
-  # Only include matches with rank >= threshold. This is a normalized rank between 0 and 100.
-  threshold = 50
-  # To get stable "See also" sections we, by default, exclude newer related pages.
-  includeNewer = true
-  # Will lower case keywords in both queries and in the indexes.
-  toLower = true
-[[related.indices]]
-name = "keywords"
-weight = 150
-[[related.indices]]
-name  = "author"
-toLower = true
-weight = 30
-[[related.indices]]
-name  = "tags"
-weight = 100
-[[related.indices]]
-name  = "date"
-weight = 10
-pattern = "2006"
-```
+    [related]
+      # Only include matches with rank >= threshold. This is a normalized rank between 0 and 100.
+      threshold = 50
+      # To get stable "See also" sections we, by default, exclude newer related pages.
+      includeNewer = true
+      # Will lower case keywords in both queries and in the indexes.
+      toLower = true
+    [[related.indices]]
+    name = "keywords"
+    weight = 150
+    [[related.indices]]
+    name  = "author"
+    toLower = true
+    weight = 30
+    [[related.indices]]
+    name  = "tags"
+    weight = 100
+    [[related.indices]]
+    name  = "date"
+    weight = 10
+    pattern = "2006"
 
 See  for more informations.
 
-Credit: [statnmap]
+Credit: [statnmap](https://github.com/statnmap)
 
-## Website SEO
+Website SEO
+-----------
 
-This theme support SEO elements for your website.
-It was adapted and integrated thanks to the following guide:  
-[https://keithpblog.org/post/hugo-website-seo/](https://keithpblog.org/post/hugo-website-seo/)
+This theme support SEO elements for your website. It was adapted and integrated thanks to the following guide:
+
 
-If you wish to enable SEO on this theme, follow these instructions:
-1. To include the following parameters in your _config.toml_
-```
-# .config.toml
-...
-enableRobotsTXT = true
-canonifyURLs = true
-# and if you think your md file names or locations might change:
-[permalinks]
-    post = "/blog/:title/"
-...
-```
+If you wish to enable SEO on this theme, follow these instructions: 1. To include the following parameters in your *config.toml* or *config.yaml*
 
-2. Add your website to Google Search Console:
-    - Login to the [Google Search Console](https://www.google.com/webmasters/tools/home)
-    - Add your website as property
-    - Add the html page as required by google to verify ownership
-    - Submit the sitemap (/sitemap.xml) for indexing
-    - Wait
+    # .config.toml
+    ...
+    googleAnalytics = "UA-XXXXX-01"
+    enableRobotsTXT = true
+    canonifyURLs = true
+    # and if you think your md file names or locations might change:
+    [permalinks]
+        post = "/blog/:title/"
+    ...
 
-3. Add your website to Bing 
-    - Login to the [Bing Webmaster Console](https://www.bing.com/toolbox/webmaster/)
-    - Add your site, details and verify
-    - From the 3 option, we recommend adding the xml file to you website
+1.  Add your website to Google Search Console:
+    -   Login to the [Google Search Console](https://www.google.com/webmasters/tools/home)
+    -   Add your website as property
+    -   Add the html page as required by google to verify ownership
+    -   Submit the sitemap (/sitemap.xml) for indexing
+    -   Wait
+2.  Add your website to Bing
+    -   Login to the [Bing Webmaster Console](https://www.bing.com/toolbox/webmaster/)
+    -   Add your site, details and verify
+    -   From the 3 option, we recommend adding the xml file to you website
 
-## Nearly finished
+Nearly finished
+---------------
 
 In order to see your site in action, run Hugo's built-in local server.
 
@@ -371,26 +343,21 @@ In order to see your site in action, run Hugo's built-in local server.
 
 Now enter [`localhost:4321`](http://localhost:4321) in the address bar of your browser.
 
-
-## Contributing
+Contributing
+------------
 
 Have you found a bug or got an idea for a new feature? Feel free to use the [issue tracker](//github.com/statnmap/hugo-statnmap-theme/issues) to let me know. Or make directly a [pull request](//github.com/statnmap/hugo-statnmap-theme/pulls).
 
-
-## License
+License
+-------
 
 This theme is released under the MIT license. For more information read the [license](https://github.com/digitalcraftsman/hugo-icarus-theme/blob/master/LICENSE.md).
 
+Acknowledgements
+----------------
 
-## Acknowledgements
-
-Thanks to 
-
-- [Digitalcraftsman](//github.com/digitalcraftsman/hugo-icarus-theme) for the original Hugo-icarus-theme
-- [Ruipeng Zhang](//github.com/ppoffice) for creating this theme
-- [Steve Francia](//github.com/spf13) for creating Hugo and the awesome community around the project
-
+Thanks to
 
-[digitalcraftsman]: //github.com/digitalcraftsman
-[statnmap]: https://github.com/statnmap
-[yihui]: https//github.com/yihui
+-   [Digitalcraftsman](//github.com/digitalcraftsman/hugo-icarus-theme) for the original Hugo-icarus-theme
+-   [Ruipeng Zhang](//github.com/ppoffice) for creating this theme
+-   [Steve Francia](//github.com/spf13) for creating Hugo and the awesome community around the project
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index d06055d..0dcb62a 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -52,6 +52,10 @@ theme = "hugo-statnmap-theme"
     highlightjsLang = ["r", "yaml"]
     highlightjsTheme = "github"
     
+    # How to cite blog article
+    disable_citation = false
+    citation_author = "Author A"
+   
     # define which types of pages should be shown. By default the type with the most regular pages
     mainSections = ["post"]
 
diff --git a/i18n/en.toml b/i18n/en.toml
index cc725cf..925d62e 100644
--- a/i18n/en.toml
+++ b/i18n/en.toml
@@ -97,3 +97,10 @@
 [page-not-found-subtitle]
   other = "The content you're looking for doesn't seem to exist."
 
+# Citation
+[citation]
+  other = "Citation:"
+[please_cite_as]
+  other = "For attribution, please cite this work as:"
+[bibtex_citation]
+  other = "BibTex citation:"
diff --git a/i18n/fr.toml b/i18n/fr.toml
index fd1c28e..d56513f 100644
--- a/i18n/fr.toml
+++ b/i18n/fr.toml
@@ -98,3 +98,10 @@
 [page-not-found-subtitle]
   other = "Le contenu que vous cherchez ne semble pas exister."
 
+# Citation
+[citation]
+  other = "Citation :"
+[please_cite_as]
+  other = "Merci de citer ce travail avec :"
+[bibtex_citation]
+  other = "Citation BibTex :"
diff --git a/layouts/partials/citation.html b/layouts/partials/citation.html
new file mode 100644
index 0000000..bfcb848
--- /dev/null
+++ b/layouts/partials/citation.html
@@ -0,0 +1,29 @@
+{{ if and (not .Site.Params.disable_citation) (not .Params.disable_citation) }}
+{{ if isset .Page.Params "citation_author" }}
+  {{ $.Scratch.Set "author" .Page.Params.citation_author}}
+{{ else }}
+  {{ if isset .Site.Params "citation_author" }}
+    {{ $.Scratch.Set "author" .Site.Params.citation_author}}
+  {{ else }}
+    {{$.Scratch.Set "author" .Page.Params.author}}
+  {{ end }}
+{{ end }}
+
+
+
+
{{ i18n "citation" }}
+

{{ i18n "please_cite_as" }}
+ +{{ ($.Scratch.Get "author")}}. ({{dateFormat "2006, Jan. 02" $.Page.Params.date }}). "{{$.Page.Params.title}}". Retrieved from {{ $.Page.Permalink | absLangURL }}. + +


+{{ i18n "bibtex_citation" }} +
@misc{{{$name_string := replace ($.Scratch.Get "author") " " ""}}{{substr $name_string 0 5}}{{dateFormat "2006" $.Page.Params.date }}{{ $title := replace $.Page.Params.title " " ""}}{{substr $title 0 5}},
+    author = {{printf "{%s}" ($.Scratch.Get "author")}},
+    title = {{$title_str := $.Page.Params.title}}{{printf "{%s}" $title_str}},
+    url = {{$url_str := ($.Page.Permalink | absLangURL)}}{{printf "{%s}" $url_str}},
+    year = {{$year_str := dateFormat "2006" $.Page.Params.date }}{{printf "{%s}" $year_str}}
+  }
+
+
+{{ end }} diff --git a/layouts/partials/single.html b/layouts/partials/single.html index 18ebdfa..03da9e1 100644 --- a/layouts/partials/single.html +++ b/layouts/partials/single.html @@ -7,6 +7,7 @@ {{ partial "article_header" . }}
{{ .Content }} + {{ partial "citation" . }}
{{ partial "article_footer" . }}