diff --git a/README.md b/README.md index 7ca9d734c..a2c767b7b 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,16 @@ Note that this repository contains solely the documentation for Hugo. For contri *Pull requests shall **only** contain changes to the actual documentation. However, changes on the code base of Hugo **and** the documentation shall be a single, atomic pull request in the [hugo](https://github.com/gohugoio/hugo) repository.* -Spelling fixes are most welcomed, and if you want to contribute longer sections to the documentation, it would be great if you had these in mind when writing: +Spelling fixes are most welcomed, and if you want to contribute longer sections to the documentation, it would be great if you had the following criteria in mind when writing: * Short is good. People go to the library to read novels. If there is more than one way to _do a thing_ in Hugo, describe the current _best practice_ (avoid "… but you can also do …" and "… in older versions of Hugo you had to …". -* For examples, try to find short snippets that teaches people about the concept. If the example is also useful as-is (copy and paste), then great, but don't list long and similar examples just so people can use them on their sites. -* Hugo has users from all over the world, so an easy to understand and [simple English](https://simple.wikipedia.org/wiki/Basic_English) is good. +* For example, try to find short snippets that teaches people about the concept. If the example is also useful as-is (copy and paste), then great. Don't list long and similar examples just so people can use them on their sites. +* Hugo has users from all over the world, so easy to understand and [simple English](https://simple.wikipedia.org/wiki/Basic_English) is good. ## Branches * The `master` branch is where the site is automatically built from, and is the place to put changes relevant to the current Hugo version. -* The `next` branch is where we store changes that is related to the next Hugo release. This can be previewed here: https://next--gohugoio.netlify.com/ +* The `next` branch is where we store changes that are related to the next Hugo release. This can be previewed here: https://next--gohugoio.netlify.com/ ## Build diff --git a/config.toml b/config.toml index 6f66955ba..2170b20c4 100644 --- a/config.toml +++ b/config.toml @@ -15,18 +15,6 @@ pluralizeListTitles = false # We do redirects via Netlify's _redirects file, generated by Hugo (see "outputs" below). disableAliases = true -# Highlighting config (Pygments) -# It is (currently) not in use, but you can do ```go in a content file if you want to. -pygmentsCodeFences = true - -pygmentsOptions = "" -# Use the Chroma stylesheet -pygmentsUseClasses = true -pygmentsUseClassic = false - -# See https://help.farbox.com/pygments.html -pygmentsStyle = "trac" - [module] [module.hugoVersion] min = "0.56.0" diff --git a/config/_default/config.toml b/config/_default/config.toml index 9f908c9fd..ec0a08f56 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -14,17 +14,11 @@ pluralizeListTitles = false # We do redirects via Netlify's _redirects file, generated by Hugo (see "outputs" below). disableAliases = true -# Highlighting config (Pygments) -# It is (currently) not in use, but you can do ```go in a content file if you want to. -pygmentsCodeFences = true - -pygmentsOptions = "" -# Use the Chroma stylesheet -pygmentsUseClasses = true -pygmentsUseClassic = false - -# See https://help.farbox.com/pygments.html -pygmentsStyle = "trac" +[markup] +[markup.highlight] +style = "trac" +lineNumbersInTable = true +noClasses = false [outputs] home = [ "HTML", "RSS", "REDIR", "HEADERS" ] diff --git a/content/en/_index.md b/content/en/_index.md index bfebd8b2f..b4e602438 100644 --- a/content/en/_index.md +++ b/content/en/_index.md @@ -43,7 +43,7 @@ sections: link: templates/ color_classes: bg-primary-color-light black image: /images/home-page-templating-example.png - copy: "Hugo's Go-based templating provides just the right amount of logic to build anything from the simple to complex. If you prefer Jade/Pug-like syntax, you can also use Amber, Ace, or any combination of the three." + copy: "Hugo's Go-based templating provides just the right amount of logic to build anything from the simple to complex." --- Hugo is one of the most popular open-source static site generators. With its amazing speed and flexibility, Hugo makes building websites fun again. diff --git a/content/en/about/features.md b/content/en/about/features.md index cadcc6b0f..a1e741ac0 100644 --- a/content/en/about/features.md +++ b/content/en/about/features.md @@ -52,7 +52,7 @@ toc: true * Integrated [Google Analytics][] support * Automatic [RSS][] creation * Support for [Go][], [Amber], and [Ace][] HTML templates -* [Syntax highlighting][] powered by [Chroma][] (partly compatible with Pygments) +* [Syntax highlighting][] powered by [Chroma][] [Ace]: /templates/alternatives/ diff --git a/content/en/content-management/formats.md b/content/en/content-management/formats.md index a0ed992f2..ea0568616 100644 --- a/content/en/content-management/formats.md +++ b/content/en/content-management/formats.md @@ -1,6 +1,6 @@ --- -title: Supported Content Formats -linktitle: Supported Content Formats +title: Content Formats +linktitle: Content Formats description: Both HTML and Markdown are supported content formats. date: 2017-01-10 publishdate: 2017-01-10 @@ -13,191 +13,37 @@ menu: weight: 20 weight: 20 #rem draft: false -aliases: [/content/markdown-extras/,/content/supported-formats/,/doc/supported-formats/,/tutorials/mathjax/] +aliases: [/content/markdown-extras/,/content/supported-formats/,/doc/supported-formats/] toc: true --- -**Markdown is the main content format** and comes in two flavours: The excellent [Blackfriday project][blackfriday] (name your files `*.md` or set `markup = "markdown"` in front matter) or its fork [Mmark][mmark] (name your files `*.mmark` or set `markup = "mmark"` in front matter), both very fast markdown engines written in Go. +You can put any file type into your `/content` directories, but Hugo uses the `markup` front matter value if set or the file extension (see `Markup identifiers` in the table below) to determine if the markup needs to be processed, e.g.: -For Emacs users, [go-org](https://github.com/niklasfasching/go-org) provides built-in native support for Org-mode (name your files `*.org` or set `markup = "org"` in front matter) +* Markdown converted to HTML +* [Shortcodes](/content-management/shortcodes/) processed +* Layout applied -But in many situations, plain HTML is what you want. Just name your files with `.html` or `.htm` extension inside your content folder. Note that if you want your HTML files to have a layout, they need front matter. It can be empty, but it has to be there: +## List of content formats -```html ---- -title: "This is a content file in HTML" ---- +The current list of content formats in Hugo: -
-

Hello, Hugo!

-
-``` +| Name | Markup identifiers | Comment | +| ------------- | ------------- |-------------| +| Goldmark | md, markdown, goldmark |Note that you can set the default handler of `md` and `markdown` to something else, see [Configure Markup](/getting-started/configuration-markup/).{{< new-in "0.60.0" >}} | +| Blackfriday | blackfriday |Blackfriday will eventually be deprecated.| +|MMark|mmark|Mmark is deprecated and will be removed in a future release.| +|Emacs Org-Mode|org|See [go-org](https://github.com/niklasfasching/go-org).| +|Asciidoc|asciidoc, adoc, ad|Needs Asciidoc or [Asciidoctor][ascii] installed.| +|RST|rst|Needs [RST](http://docutils.sourceforge.net/rst.html) installed.| +|Pandoc|pandoc, pdc|Needs [Pandoc](https://www.pandoc.org/) installed.| +|HTML|html, htm|To be treated as a content file, with layout, shortcodes etc., it must have front matter. If not, it will be copied as-is.| -{{% note "Deeply Nested Lists" %}} -Before you begin writing your content in markdown, Blackfriday has a known issue [(#329)](https://github.com/russross/blackfriday/issues/329) with handling deeply nested lists. Luckily, there is an easy workaround. Use 4-spaces (i.e., tab) rather than 2-space indentations. -{{% /note %}} +The `markup identifier` is fetched from either the `markup` variable in front matter or from the file extension. For markup-related configuration, see [Configure Markup](/getting-started/configuration-markup/). -## Configure BlackFriday Markdown Rendering -You can configure multiple aspects of Blackfriday as shown in the following list. See the docs on [Configuration][config] for the full list of explicit directions you can give to Hugo when rendering your site. +## External Helpers -{{< readfile file="/content/en/readfiles/bfconfig.md" markdown="true" >}} - -## Extend Markdown - -Hugo provides some convenient methods for extending markdown. - -### Task Lists - -Hugo supports [GitHub-styled task lists (i.e., TODO lists)][gfmtasks] for the Blackfriday markdown renderer. If you do not want to use this feature, you can disable it in your configuration. - -#### Example Task List Input - -{{< code file="content/my-to-do-list.md" >}} -- [ ] a task list item -- [ ] list syntax required -- [ ] incomplete -- [x] completed -{{< /code >}} - -#### Example Task List Output - -The preceding markdown produces the following HTML in your rendered website: - -``` - -``` - -#### Example Task List Display - -The following shows how the example task list will look to the end users of your website. Note that visual styling of lists is up to you. This list has been styled according to [the Hugo Docs stylesheet][hugocss]. - -- [ ] a task list item -- [ ] list syntax required -- [ ] incomplete -- [x] completed - -### Emojis - -To add emojis directly to content, set `enableEmoji` to `true` in your [site configuration][config]. To use emojis in templates or shortcodes, see [`emojify` function][]. - -For a full list of emojis, see the [Emoji cheat sheet][emojis]. - -### Shortcodes - -If you write in Markdown and find yourself frequently embedding your content with raw HTML, Hugo provides built-in shortcodes functionality. This is one of the most powerful features in Hugo and allows you to create your own Markdown extensions very quickly. - -See [Shortcodes][sc] for usage, particularly for the built-in shortcodes that ship with Hugo, and [Shortcode Templating][sct] to learn how to build your own. - -### Code Blocks - -Hugo supports GitHub-flavored markdown's use of triple back ticks, as well as provides a special [`highlight` shortcode][hlsc], and syntax highlights those code blocks natively using *Chroma*. Users also have an option to use *Pygments* instead. See the [Syntax Highlighting][hl] section for details. - -## Mmark - -Mmark is a [fork of BlackFriday][mmark] and markdown superset that is well suited for writing [IETF documentation][ietf]. You can see examples of the syntax in the [Mmark GitHub repository][mmark] or the full syntax on [Miek Gieben's website][]. - -### Use Mmark - -As Hugo ships with Mmark, using the syntax is as easy as changing the extension of your content files from `.md` to `.mmark`. - -In the event that you want to only use Mmark in specific files, you can also define the Mmark syntax in your content's front matter: - -``` ---- -title: My Post -date: 2017-04-01 -markup: mmark ---- -``` - -{{% warning %}} -Thare are some features not available in Mmark; one example being that shortcodes are not translated when used in an included `.mmark` file ([#3131](https://github.com/gohugoio/hugo/issues/3137)), and `EXTENSION_ABBREVIATION` ([#1970](https://github.com/gohugoio/hugo/issues/1970)) and the aforementioned GFM todo lists ([#2270](https://github.com/gohugoio/hugo/issues/2270)) are not fully supported. Contributions are welcome. -{{% /warning %}} - -## MathJax with Hugo - -[MathJax](https://www.mathjax.org/) is a JavaScript library that allows the display of mathematical expressions described via a LaTeX-style syntax in the HTML (or Markdown) source of a web page. As it is a pure a JavaScript library, getting it to work within Hugo is fairly straightforward, but does have some oddities that will be discussed here. - -This is not an introduction into actually using MathJax to render typeset mathematics on your website. Instead, this page is a collection of tips and hints for one way to get MathJax working on a website built with Hugo. - -### Enable MathJax - -The first step is to enable MathJax on pages that you would like to have typeset math. There are multiple ways to do this (adventurous readers can consult the [Loading and Configuring](https://docs.mathjax.org/en/latest/web/configuration.html) section of the MathJax documentation for additional methods of including MathJax), but the easiest way is to use the secure MathJax CDN by include a ` -{{< /code >}} - -One way to ensure that this code is included in all pages is to put it in one of the templates that live in the `layouts/partials/` directory. For example, I have included this in the bottom of my template `footer.html` because I know that the footer will be included in every page of my website. - -### Options and Features - -MathJax is a stable open-source library with many features. I encourage the interested reader to view the [MathJax Documentation](https://docs.mathjax.org/en/latest/index.html), specifically the sections on [Basic Usage](http://docs.mathjax.org/en/latest/index.html#basic-usage) and [MathJax Configuration Options](http://docs.mathjax.org/en/latest/index.html#mathjax-configuration-options). - -### Issues with Markdown - -{{% note %}} -The following issues with Markdown assume you are using `.md` for content and BlackFriday for parsing. Using [Mmark](#mmark) as your content format will obviate the need for the following workarounds. - -When using Mmark with MathJax, use `displayMath: [['$$','$$'], ['\\[','\\]']]`. See the [Mmark `README.md`](https://github.com/miekg/mmark/wiki/Syntax#math-blocks) for more information. In addition to MathJax, Mmark has been shown to work well with [KaTeX](https://github.com/Khan/KaTeX). See this [related blog post from a Hugo user](http://nosubstance.me/post/a-great-toolset-for-static-blogging/). -{{% /note %}} - -After enabling MathJax, any math entered between proper markers (see the [MathJax documentation][mathjaxdocs]) will be processed and typeset in the web page. One issue that comes up, however, with Markdown is that the underscore character (`_`) is interpreted by Markdown as a way to wrap text in `emph` blocks while LaTeX (MathJax) interprets the underscore as a way to create a subscript. This "double speak" of the underscore can result in some unexpected and unwanted behavior. - -### Solution - -There are multiple ways to remedy this problem. One solution is to simply escape each underscore in your math code by entering `\_` instead of `_`. This can become quite tedious if the equations you are entering are full of subscripts. - -Another option is to tell Markdown to treat the MathJax code as verbatim code and not process it. One way to do this is to wrap the math expression inside a `
` `
` block. Markdown would ignore these sections and they would get passed directly on to MathJax and processed correctly. This works great for display style mathematics, but for inline math expressions the line break induced by the `
` is not acceptable. The syntax for instructing Markdown to treat inline text as verbatim is by wrapping it in backticks (`` ` ``). You might have noticed, however, that the text included in between backticks is rendered differently than standard text (on this site these are items highlighted in red). To get around this problem, we could create a new CSS entry that would apply standard styling to all inline verbatim text that includes MathJax code. Below I will show the HTML and CSS source that would accomplish this (note this solution was adapted from [this blog post](http://doswa.com/2011/07/20/mathjax-in-markdown.html)---all credit goes to the original author). - -{{< code file="mathjax-markdown-solution.html" >}} - -{{< /code >}} - -As before, this content should be included in the HTML source of each page that will be using MathJax. The next code snippet contains the CSS that is used to have verbatim MathJax blocks render with the same font style as the body of the page. - -{{< code file="mathjax-style.css" >}} -code.has-jax { - font: inherit; - font-size: 100%; - background: inherit; - border: inherit; - color: #515151; -} -{{< /code >}} - -In the CSS snippet, notice the line `color: #515151;`. `#515151` is the value assigned to the `color` attribute of the `body` class in my CSS. In order for the equations to fit in with the body of a web page, this value should be the same as the color of the body. - -### Usage - -With this setup, everything is in place for a natural usage of MathJax on pages generated using Hugo. In order to include inline mathematics, just put LaTeX code in between `` `$ TeX Code $` `` or `` `\( TeX Code \)` ``. To include display style mathematics, just put LaTeX code in between `
$$TeX Code$$
`. All the math will be properly typeset and displayed within your Hugo generated web page! - -## Additional Formats Through External Helpers - -Hugo has a new concept called _external helpers_. It means that you can write your content using [Asciidoc][ascii], [reStructuredText][rest], or [pandoc]. If you have files with associated extensions, Hugo will call external commands to generate the content. ([See the Hugo source code for external helpers][helperssource].) - -For example, for Asciidoc files, Hugo will try to call the `asciidoctor` or `asciidoc` command. This means that you will have to install the associated tool on your machine to be able to use these formats. ([See the Asciidoctor docs for installation instructions](https://asciidoctor.org/docs/install-toolchain/)). - -To use these formats, just use the standard extension and the front matter exactly as you would do with natively supported `.md` files. +Some of the formats in the table above needs external helpers installed on your PC. For example, for Asciidoc files, Hugo will try to call the `asciidoctor` or `asciidoc` command. This means that you will have to install the associated tool on your machine to be able to use these formats. ([See the Asciidoctor docs for installation instructions](https://asciidoctor.org/docs/install-toolchain/)). Hugo passes reasonable default arguments to these external helpers by default: diff --git a/content/en/content-management/image-processing/index.md b/content/en/content-management/image-processing/index.md index 9ec0734cc..53e72bee1 100644 --- a/content/en/content-management/image-processing/index.md +++ b/content/en/content-management/image-processing/index.md @@ -98,11 +98,12 @@ Tags: {{ range $k, $v := .Tags }} TAG: {{ $k }}: {{ $v }} {{ end }} +{{ end }} ``` #### Exif fields -Data +Date : "photo taken" date/time Lat diff --git a/content/en/content-management/syntax-highlighting.md b/content/en/content-management/syntax-highlighting.md index 6b277365f..1220a06c8 100644 --- a/content/en/content-management/syntax-highlighting.md +++ b/content/en/content-management/syntax-highlighting.md @@ -3,7 +3,7 @@ title: Syntax Highlighting description: Hugo comes with really fast syntax highlighting from Chroma. date: 2017-02-01 publishdate: 2017-02-01 -keywords: [highlighting,pygments,chroma,code blocks,syntax] +keywords: [highlighting,chroma,code blocks,syntax] categories: [content management] menu: docs: @@ -16,17 +16,39 @@ aliases: [/extras/highlighting/,/extras/highlight/,/tools/syntax-highlighting/] toc: true --- -From Hugo 0.28, the default syntax highlighter in Hugo is [Chroma](https://github.com/alecthomas/chroma); it is built in Go and is really, really fast -- and for the most important parts compatible with Pygments. -If you want to continue to use Pygments (see below), set `pygmentsUseClassic=true` in your site config. +Hugo uses [Chroma](https://github.com/alecthomas/chroma) as its code highlighter; it is built in Go and is really, really fast -- and for the most important parts compatible with Pygments we used before. -The example below shows a simple code snippet from the Hugo source highlighted with the `highlight` shortcode. Note that the gohugo.io site is generated with `pygmentsUseClasses=true` (see [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css)). +## Configure Syntax Highlighter -* `linenos=inline` or `linenos=table` (`table` will give copy-and-paste friendly code blocks) turns on line numbers. -* `hl_lines` lists a set of line numbers or line number ranges to be highlighted. Note that the hyphen range syntax is only supported for Chroma. +See [Configure Highlight](/getting-started/configuration-markup#highlight). + + +## Generate Syntax Highlighter CSS + +If you run with `pygmentsUseClasses=true` in your site config, you need a style sheet. + +You can generate one with Hugo: + +```bash +hugo gen chromastyles --style=monokai > syntax.css +``` + +Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/splash/docs/ for a gallery of available styles. + + +## Highlight Shortcode + +Highlighting is carried out via the [built-in shortcode](/content-management/shortcodes/) `highlight`. `highlight` takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. + +Options: + +* `linenos`: Valid values are `true`, `false`, `table`, `inline`. `table` will give copy-and-paste friendly code blocks) turns on line numbers. +* Setting `linenos` to `false` will turn off linenumbers if it's configured to be on in site config.{{< new-in "0.60.0" >}} +* `hl_lines` lists a set of line numbers or line number ranges to be highlighted. * `linenostart=199` starts the line number count from 199. -With that, this: +### Example: Highlight Shortcode ``` {{}} @@ -52,144 +74,65 @@ func GetTitleFunc(style string) func(s string) string { case "go": return strings.Title case "chicago": - tc := transform.NewTitleConverter(transform.ChicagoStyle) - return tc.Title + return transform.NewTitleConverter(transform.ChicagoStyle) default: - tc := transform.NewTitleConverter(transform.APStyle) - return tc.Title + return transform.NewTitleConverter(transform.APStyle) } } {{< / highlight >}} -## Configure Syntax Highlighter -To make the transition from Pygments to Chroma seamless, they share a common set of configuration options: - -pygmentsOptions -: A comma separated list of options. See below for a full list. - -pygmentsCodeFences -: Set to true to enable syntax highlighting in code fences with a language tag in markdown (see below for an example). - -pygmentsStyle -: The style of code highlighting. Note that this option is not - relevant when `pygmentsUseClasses` is set. - - Syntax highlighting galleries: - **Chroma** ([short snippets](https://xyproto.github.io/splash/docs/all.html), - [long snippets](https://xyproto.github.io/splash/docs/longer/all.html)), - [Pygments](https://help.farbox.com/pygments.html) - -pygmentsUseClasses -: Set to `true` to use CSS classes to format your highlighted code. See [Generate Syntax Highlighter CSS](#generate-syntax-highlighter-css). - -pygmentsCodeFencesGuessSyntax -: Set to `true` to try to do syntax highlighting on code fenced blocks in markdown without a language tag. - -pygmentsUseClassic -: Set to true to use Pygments instead of the much faster Chroma. - -### Options - -`pygmentsOptions` can be set either in site config or overridden per code block in the Highlight shortcode or template func. - -noclasses -: Use inline style. - -linenos -: For Chroma, any value in this setting will print line numbers. Pygments has some more fine grained control. - -linenostart -: Start the line numbers from this value (default is 1). - - -hl_lines -: Highlight a space separated list of line numbers. For Chroma, you can provide a list of ranges, i.e. "3-8 10-20". - - -The full set of supported options for Pygments is: `encoding`, `outencoding`, `nowrap`, `full`, `title`, `style`, `noclasses`, `classprefix`, `cssclass`, `cssstyles`, `prestyles`, `linenos`, `hl_lines`, `linenostart`, `linenostep`, `linenospecial`, `nobackground`, `lineseparator`, `lineanchors`, `linespans`, `anchorlinenos`, `startinline`. See the [Pygments HTML Formatter Documentation](http://pygments.org/docs/formatters/#HtmlFormatter) for details. - - -## Generate Syntax Highlighter CSS - -If you run with `pygmentsUseClasses=true` in your site config, you need a style sheet. - -You can generate one with Hugo: - -```bash -hugo gen chromastyles --style=monokai > syntax.css -``` - -Run `hugo gen chromastyles -h` for more options. See https://xyproto.github.io/splash/docs/ for a gallery of available styles. - - -## Highlight Shortcode - -Highlighting is carried out via the [built-in shortcode](/content-management/shortcodes/) `highlight`. `highlight` takes exactly one required parameter for the programming language to be highlighted and requires a closing shortcode. Note that `highlight` is *not* used for client-side javascript highlighting. - -### Example `highlight` Shortcode - -{{< code file="example-highlight-shortcode-input.md" >}} -{{}} -
-
-

{{ .Title }}

- {{ range .Pages }} - {{ .Render "summary"}} - {{ end }} -
-
-{{}} -{{< /code >}} - - ## Highlight Template Func See [Highlight](/functions/highlight/). -## Highlight in Code Fences +## Highlighting in Code Fences -It is also possible to add syntax highlighting with GitHub flavored code fences. To enable this, set the `pygmentsCodeFences` to `true` in Hugo's [configuration file](/getting-started/configuration/); +Highlighting in code fences is enabled by default.{{< new-in "0.60.0" >}} ```` -```go-html-template -
-
-

{{ .Title }}

- {{ range .Pages }} - {{ .Render "summary"}} - {{ end }} -
-
+```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199} +// ... code ``` ```` + +Gives this: + +```go {linenos=table,hl_lines=[8,"15-17"],linenostart=199} +// GetTitleFunc returns a func that can be used to transform a string to +// title case. +// +// The supported styles are +// +// - "Go" (strings.Title) +// - "AP" (see https://www.apstylebook.com/) +// - "Chicago" (see https://www.chicagomanualofstyle.org/home.html) +// +// If an unknown or empty style is provided, AP style is what you get. +func GetTitleFunc(style string) func(s string) string { + switch strings.ToLower(style) { + case "go": + return strings.Title + case "chicago": + return transform.NewTitleConverter(transform.ChicagoStyle) + default: + return transform.NewTitleConverter(transform.APStyle) + } +} +``` + +{{< new-in "0.60.0" >}}Note that only Goldmark supports passing attributes such as `hl_lines`, and it's important that it does not contain any spaces. See [goldmark-highlighting](https://github.com/yuin/goldmark-highlighting) for more information. + +The options are the same as in the [highlighting shortcode](/content-management/syntax-highlighting/#highlight-shortcode),including `linenos=false`, but note the slightly different Markdown attribute syntax. + ## List of Chroma Highlighting Languages The full list of Chroma lexers and their aliases (which is the identifier used in the `highlight` template func or when doing highlighting in code fences): {{< chroma-lexers >}} -## Highlight with Pygments Classic - -If you for some reason don't want to use the built-in Chroma highlighter, you can set `pygmentsUseClassic=true` in your config and add Pygments to your path. - -{{% note "Disclaimers on Pygments" %}} -* Pygments is relatively slow and _causes a performance hit when building your site_, but Hugo has been designed to cache the results to disk. -* The caching can be turned off by setting the `--ignoreCache` flag to `true`. -* The languages available for highlighting depend on your Pygments installation. -{{% /note %}} - -If you have never worked with Pygments before, here is a brief primer: - -+ Install Python from [python.org](https://www.python.org/downloads/). Version 2.7.x is already sufficient. -+ Run `pip install Pygments` in order to install Pygments. Once installed, Pygments gives you a command `pygmentize`. Make sure it sits in your PATH; otherwise, Hugo will not be able to find and use it. - -On Debian and Ubuntu systems, you may also install Pygments by running `sudo apt-get install python3-pygments`. - - - [Prism]: https://prismjs.com [prismdownload]: https://prismjs.com/download.html [Highlight.js]: https://highlightjs.org/ diff --git a/content/en/content-management/toc.md b/content/en/content-management/toc.md index 31326746c..fbb2df065 100644 --- a/content/en/content-management/toc.md +++ b/content/en/content-management/toc.md @@ -18,7 +18,11 @@ toc: true --- {{% note "TOC Heading Levels are Fixed" %}} -Currently, the `{{.TableOfContents}}` [page variable](/variables/page/) does not allow you to specify which heading levels you want the TOC to render. [See the related GitHub discussion (#1778)](https://github.com/gohugoio/hugo/issues/1778). As such, the resulting `` is going to start at `

` when pulling from `{{.Content}}`. + +Previously, there was no out-of-the-box way to specify which heading levels you want the TOC to render. [See the related GitHub discussion (#1778)](https://github.com/gohugoio/hugo/issues/1778). As such, the resulting `` was going to start at `

` when pulling from `{{.Content}}`. + +Hugo [v0.60.0](https://github.com/gohugoio/hugo/releases/tag/v0.60.0) made a switch to [Goldmark](https://github.com/yuin/goldmark/) as the default library for Markdown which has improved and configurable implementation of TOC. Take a look at [how to configure TOC](/getting-started/configuration-markup/#table-of-contents) for Goldmark renderer. + {{% /note %}} ## Usage @@ -43,7 +47,7 @@ A collection of textile samples lay spread out on the table - Samsa was a travel Hugo will take this Markdown and create a table of contents from `## Introduction`, `## My Heading`, and `### My Subheading` and then store it in the [page variable][pagevars]`.TableOfContents`. -The built-in `.TableOfContents` variables outputs a `

{{< /code >}} -{{% note %}} -The preceding shortcode makes use of a Hugo-specific template function called `highlight`, which uses [Pygments](http://pygments.org) to add syntax highlighting to the example HTML code block. See the [developer tools page on syntax highlighting](/tools/syntax-highlighting/) for more information. -{{% /note %}} - ### Nested Shortcode: Image Gallery Hugo's [`.Parent` shortcode variable][parent] returns a boolean value depending on whether the shortcode in question is called within the context of a *parent* shortcode. This provides an inheritance model for common shortcode parameters. diff --git a/content/en/tools/search.md b/content/en/tools/search.md index 2958ee0a0..4c6695976 100644 --- a/content/en/tools/search.md +++ b/content/en/tools/search.md @@ -18,7 +18,7 @@ aliases: [] toc: true --- -A static website with a dynamic search function? Yes. As alternatives to embeddable scripts from Google or other search engines, you can provide your visitors a custom search by indexing your content files directly. +A static website with a dynamic search function? Yes, Hugo provides an alternative to embeddable scripts from Google or other search engines for static websites. Hugo allows you to provide your visitors with a custom search function by indexing your content files directly. * [GitHub Gist for Hugo Workflow](https://gist.github.com/sebz/efddfc8fdcb6b480f567). This gist contains a simple workflow to create a search index for your static website. It uses a simple Grunt script to index all your content files and [lunr.js](https://lunrjs.com/) to serve the search results. * [hugo-elasticsearch](https://www.npmjs.com/package/hugo-elasticsearch). Generate [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html) indexes for Hugo static sites by parsing front matter. Hugo-Elasticsearch will generate a newline delimited JSON (NDJSON) file that can be bulk uploaded into Elasticsearch using any one of the available [clients](https://www.elastic.co/guide/en/elasticsearch/client/index.html). diff --git a/data/docs.json b/data/docs.json index 1c09a788e..0944ab881 100644 --- a/data/docs.json +++ b/data/docs.json @@ -1,6 +1,13 @@ { "chroma": { "lexers": [ + { + "Name": "ABAP", + "Aliases": [ + "ABAP", + "abap" + ] + }, { "Name": "ABNF", "Aliases": [ @@ -134,6 +141,13 @@ "winbatch" ] }, + { + "Name": "BibTeX", + "Aliases": [ + "bib", + "bibtex" + ] + }, { "Name": "BlitzBasic", "Aliases": [ @@ -405,7 +419,8 @@ "Aliases": [ "forth", "frt", - "fs" + "fs", + "fth" ] }, { @@ -579,12 +594,27 @@ "idris" ] }, + { + "Name": "Igor", + "Aliases": [ + "igor", + "igorpro", + "ipf" + ] + }, { "Name": "Io", "Aliases": [ "io" ] }, + { + "Name": "J", + "Aliases": [ + "ijs", + "j" + ] + }, { "Name": "JSON", "Aliases": [ @@ -1342,6 +1372,63 @@ } ] }, + "config": { + "markup": { + "defaultMarkdownHandler": "goldmark", + "highlight": { + "style": "monokai", + "codeFences": true, + "noClasses": true, + "lineNos": false, + "lineNumbersInTable": true, + "lineNoStart": 1, + "hl_Lines": "", + "tabWidth": 4 + }, + "tableOfContents": { + "startLevel": 2, + "endLevel": 3 + }, + "goldmark": { + "renderer": { + "hardWraps": false, + "xHTML": false, + "unsafe": false + }, + "parser": { + "autoHeadingID": true, + "attribute": true + }, + "extensions": { + "typographer": true, + "footnote": true, + "definitionList": true, + "table": true, + "strikethrough": true, + "linkify": true, + "taskList": true + } + }, + "blackFriday": { + "smartypants": true, + "smartypantsQuotesNBSP": false, + "angledQuotes": false, + "fractions": true, + "hrefTargetBlank": false, + "nofollowLinks": false, + "noreferrerLinks": false, + "smartDashes": true, + "latexDashes": true, + "taskLists": true, + "plainIDAnchors": true, + "extensions": null, + "extensionsMask": null, + "skipHTML": false, + "footnoteAnchorPrefix": "", + "footnoteReturnLinkContents": "" + } + } + }, "media": { "types": [ { @@ -1513,6 +1600,68 @@ "suffixes": [ "scss" ] + }, + { + "type": "video/3gpp", + "string": "video/3gpp", + "mainType": "video", + "subType": "3gpp", + "delimiter": ".", + "suffixes": [ + "3gpp", + "3gp" + ] + }, + { + "type": "video/mp4", + "string": "video/mp4", + "mainType": "video", + "subType": "mp4", + "delimiter": ".", + "suffixes": [ + "mp4" + ] + }, + { + "type": "video/mpeg", + "string": "video/mpeg", + "mainType": "video", + "subType": "mpeg", + "delimiter": ".", + "suffixes": [ + "mpg", + "mpeg" + ] + }, + { + "type": "video/ogg", + "string": "video/ogg", + "mainType": "video", + "subType": "ogg", + "delimiter": ".", + "suffixes": [ + "ogv" + ] + }, + { + "type": "video/webm", + "string": "video/webm", + "mainType": "video", + "subType": "webm", + "delimiter": ".", + "suffixes": [ + "webm" + ] + }, + { + "type": "video/x-msvideo", + "string": "video/x-msvideo", + "mainType": "video", + "subType": "x-msvideo", + "delimiter": ".", + "suffixes": [ + "avi" + ] } ] }, @@ -2290,10 +2439,10 @@ ] }, "Eq": { - "Description": "Eq returns the boolean truth of arg1 == arg2.", + "Description": "Eq returns the boolean truth of arg1 == arg2 || arg1 == arg3 || arg1 == arg4.", "Args": [ - "x", - "y" + "first", + "others" ], "Aliases": [ "eq" @@ -2454,7 +2603,7 @@ ] }, "Dictionary": { - "Description": "Dictionary creates a map[string]interface{} from the given parameters by\nwalking the parameters and treating them as key-value pairs. The number\nof parameters must be even.", + "Description": "Dictionary creates a map[string]interface{} from the given parameters by\nwalking the parameters and treating them as key-value pairs. The number\nof parameters must be even.\nThe keys can be string slices, which will create the needed nested structure.", "Args": [ "values" ], @@ -2521,7 +2670,7 @@ "Description": "Index returns the result of indexing its first argument by the following\narguments. Thus \"index x 1 2 3\" is, in Go syntax, x[1][2][3]. Each\nindexed item must be a map, slice, or array.\n\nCopied from Go stdlib src/text/template/funcs.go.\n\nWe deviate from the stdlib due to https://github.com/golang/go/issues/14751.\n\nTODO(moorereason): merge upstream changes.", "Args": [ "item", - "indices" + "args" ], "Aliases": [ "index" @@ -2630,6 +2779,12 @@ ] ] }, + "Reverse": { + "Description": "", + "Args": null, + "Aliases": null, + "Examples": null + }, "Seq": { "Description": "Seq creates a sequence of integers. It's named and used as GNU's seq.\n\nExamples:\n 3 =\u003e 1, 2, 3\n 1 2 4 =\u003e 1, 3\n -3 =\u003e -1, -2, -3\n 1 4 =\u003e 1, 2, 3, 4\n 1 -2 =\u003e 1, 0, -1, -2", "Args": [ diff --git a/data/homepagetweets.toml b/data/homepagetweets.toml index b5f2d1b59..f5a2b5dbe 100644 --- a/data/homepagetweets.toml +++ b/data/homepagetweets.toml @@ -1,3 +1,10 @@ +[[tweet]] +name = "Heinrich Hartmann" +twitter_handle = "@heinrichhartman" +quote = "Working with @GoHugoIO is such a joy. Having worked with #Jekyll in the past, the near instant preview is a big win! Did not expect this to make such a huge difference." +link = "https://twitter.com/heinrichhartman/status/1199736512264462341" +date = 2019-11-12T00:00:00Z + [[tweet]] name = "Joshua Steven‏‏" twitter_handle = "@jscarto" diff --git a/layouts/shortcodes/code-toggle.html b/layouts/shortcodes/code-toggle.html new file mode 100644 index 000000000..da4b00719 --- /dev/null +++ b/layouts/shortcodes/code-toggle.html @@ -0,0 +1,34 @@ +{{ $file := .Get "file" }} +{{ $code := "" }} +{{ with .Get "config" }} +{{ $file = $file | default "config" }} +{{ $sections := (split . ".") }} +{{ $configSection := index $.Site.Data.docs.config $sections }} +{{ $code = dict $sections $configSection }} +{{ else }} +{{ $code = $.Inner }} +{{ end }} +{{ $langs := (slice "yaml" "toml" "json") }} +
+
+ {{- with $file -}} +
{{ . }}.
+ {{- end -}} + {{ range $langs }} +   + {{ end }} +
+
+ {{ range $langs }} +
+ {{ highlight ($code | transform.Remarshal . | safeHTML) . ""}} +
+ {{ if ne ($.Get "copy") "false" }} + + {{/* Functionality located within filesaver.js The copy here is located in the css with .copy class so it can be replaced with JS on success */}} + {{end}} + {{ end }} +
+ +
diff --git a/layouts/shortcodes/new-in.html b/layouts/shortcodes/new-in.html new file mode 100644 index 000000000..ab0abb273 --- /dev/null +++ b/layouts/shortcodes/new-in.html @@ -0,0 +1,8 @@ +{{ $version := .Get 0 }} +{{ if not $version }} +{{ errorf "Missing version in new-in shortcode "}} +{{ end }} +{{ $version = $version | strings.TrimPrefix "v" }} + \ No newline at end of file diff --git a/netlify.toml b/netlify.toml index 269d138ab..f35a7c0f0 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,7 +3,7 @@ publish = "public" command = "hugo --gc --minify" [context.production.environment] -HUGO_VERSION = "0.59.1" +HUGO_VERSION = "0.61.0" HUGO_ENV = "production" HUGO_ENABLEGITINFO = "true" @@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true" command = "hugo --gc --minify --enableGitInfo" [context.split1.environment] -HUGO_VERSION = "0.59.1" +HUGO_VERSION = "0.61.0" HUGO_ENV = "production" [context.deploy-preview] command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL" [context.deploy-preview.environment] -HUGO_VERSION = "0.59.1" +HUGO_VERSION = "0.61.0" [context.branch-deploy] command = "hugo --gc --minify -b $DEPLOY_PRIME_URL" [context.branch-deploy.environment] -HUGO_VERSION = "0.59.1" +HUGO_VERSION = "0.61.0" [context.next.environment] HUGO_ENABLEGITINFO = "true" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e0f2f62df..000000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Pygments==2.1.3 diff --git a/resources/_gen/images/news/0.60.0-relnotes/poster-featured_hu88aba11293facef11feec48164ba6c3f_31907_480x0_resize_catmullrom_2.png b/resources/_gen/images/news/0.60.0-relnotes/poster-featured_hu88aba11293facef11feec48164ba6c3f_31907_480x0_resize_catmullrom_2.png new file mode 100644 index 000000000..bca6dc8a8 Binary files /dev/null and b/resources/_gen/images/news/0.60.0-relnotes/poster-featured_hu88aba11293facef11feec48164ba6c3f_31907_480x0_resize_catmullrom_2.png differ diff --git a/resources/_gen/images/news/0.60.0-relnotes/poster-featured_hu88aba11293facef11feec48164ba6c3f_31907_640x0_resize_catmullrom_2.png b/resources/_gen/images/news/0.60.0-relnotes/poster-featured_hu88aba11293facef11feec48164ba6c3f_31907_640x0_resize_catmullrom_2.png new file mode 100644 index 000000000..558a151c9 Binary files /dev/null and b/resources/_gen/images/news/0.60.0-relnotes/poster-featured_hu88aba11293facef11feec48164ba6c3f_31907_640x0_resize_catmullrom_2.png differ diff --git a/resources/_gen/images/news/0.60.1-relnotes/featured-061_hu55b86d71cf1e6f4fec276be0fe0d3e6e_28841_480x0_resize_catmullrom_2.png b/resources/_gen/images/news/0.60.1-relnotes/featured-061_hu55b86d71cf1e6f4fec276be0fe0d3e6e_28841_480x0_resize_catmullrom_2.png new file mode 100644 index 000000000..61d552d8c Binary files /dev/null and b/resources/_gen/images/news/0.60.1-relnotes/featured-061_hu55b86d71cf1e6f4fec276be0fe0d3e6e_28841_480x0_resize_catmullrom_2.png differ diff --git a/resources/_gen/images/news/0.60.1-relnotes/featured-061_hu55b86d71cf1e6f4fec276be0fe0d3e6e_28841_640x0_resize_catmullrom_2.png b/resources/_gen/images/news/0.60.1-relnotes/featured-061_hu55b86d71cf1e6f4fec276be0fe0d3e6e_28841_640x0_resize_catmullrom_2.png new file mode 100644 index 000000000..cc3a4e4c3 Binary files /dev/null and b/resources/_gen/images/news/0.60.1-relnotes/featured-061_hu55b86d71cf1e6f4fec276be0fe0d3e6e_28841_640x0_resize_catmullrom_2.png differ diff --git a/resources/_gen/images/news/0.61.0-relnotes/hugo-61-featured_huc7cf44fd2ae7c41ccbb87bf5c4aa169c_79929_480x0_resize_catmullrom_2.png b/resources/_gen/images/news/0.61.0-relnotes/hugo-61-featured_huc7cf44fd2ae7c41ccbb87bf5c4aa169c_79929_480x0_resize_catmullrom_2.png new file mode 100644 index 000000000..bee94364e Binary files /dev/null and b/resources/_gen/images/news/0.61.0-relnotes/hugo-61-featured_huc7cf44fd2ae7c41ccbb87bf5c4aa169c_79929_480x0_resize_catmullrom_2.png differ diff --git a/resources/_gen/images/news/0.61.0-relnotes/hugo-61-featured_huc7cf44fd2ae7c41ccbb87bf5c4aa169c_79929_640x0_resize_catmullrom_2.png b/resources/_gen/images/news/0.61.0-relnotes/hugo-61-featured_huc7cf44fd2ae7c41ccbb87bf5c4aa169c_79929_640x0_resize_catmullrom_2.png new file mode 100644 index 000000000..cc28f5b9a Binary files /dev/null and b/resources/_gen/images/news/0.61.0-relnotes/hugo-61-featured_huc7cf44fd2ae7c41ccbb87bf5c4aa169c_79929_640x0_resize_catmullrom_2.png differ