Why are headings automatically creating links in GitHub readme.md markdown pages? - github

Hello: I have created readme.md files for my repositories and GitHub pages. But when I create headings that are formatted h2/## or h3/###, etc. in-page anchor links are automatically created. I have tried different ways to format the headings -- such as ##, , --- -- but I get the same result. It occurs with each heading. This occurs in readme.md files that are in the repository and those that are converted to GitHub pages. I've tested it in chrome browser and edge browser and it's the same behavior.
# sample will create the heading and an unwanted in-page link
## sample will create the heading and an unwanted in-page link
Here's a page with the behavior: https://burrittresearch.com/
My goal is to be able to format headings in markdown without having these links automatically created.
Thank you!

Those are part of the anchorjs default CSS rules from GitHub pages
<h2 id="skills">Skills
<a class="anchorjs-link"
href="#skills"
aria-label="Anchor"
data-anchorjs-icon=""
style="font: 1em / 1 anchorjs-icons; padding-left: 0.375em;">
</a>
</h2>
If you static page (like this one) include its own set of CSS file/rules (like those ones), you could add, to make sure they are not visible:
.anchorjs-link {
display: none !Important;
}

GitHub documents their markup processing in github/Markup. Note that Markdown is converted to HTML in step one, which does not add any anchors to headers. However, in step 4, which is separate from the Markdown parsing, all headers in the document have anchors added. This is done to all content, regardless of whether is comes from Markdown, ReStructured Text, textile, asscidoc, etc., and is not specific to Markdown.
Note that the above only applies to content supplied by users which is displayed on github.com. It is their site, which they control, so we don't get to change/override that behavior.
However, it is different with GitHub pages. By default, GitHub Pages uses Jekyll to convert Markdown files into HTML. Jekyll includes a number of options to control how Markdown is processed, including the auto_ids option. Turn that option off (set it to false), and Jekyll will no longer add IDs to every header. However, that is a Kramdown option, but, as I understand if, GitHub Pages uses the GitHub Flavored Markdown variant of Commonmark, which doesn't have any such options. For that matter, the GFM spec doesn't indicate that headers would be assigned IDs either (so I'm not sure where those IDs are coming from). You might try configuring Jekyll to use Kramdown with the auto_ids option turned off. Configuration options "can either be specified in a _config.yml or _config.toml file placed in your site’s root directory."
As an alternative, you could install Jekyll (or any other static site generator) locally and build the site before uploading to GitHub Pages. Simply include an empty file named .nojekyll in the site root and GitHub will not run your files through Jekyll. In this way, you get complete control over the content and formatting of the pages.

Related

Github Jekyll theme hacker style does not apply to sublinks

I created a GitHub page with a hacker theme.
Then, I created another .md file (other than the index.md) and linked it to the index file.
The referenced .md (named as testlink.md) does not have the same style, unfortunately.
Here is the code: https://github.com/YesimSem/thecuriousanimal/tree/gh-pages
How may I ensure that all the .md files have that same style?
Thank you,
Updated Answer
Your link needs to be changed from .md to .html. Please see this pull request on your repository for the fix. The testlink.md is being rendered correctly but your link is going to the original Markdown file. It should be going to the HTML rendering of the Markdown file. See this URL for the correct page https://yesimsem.github.io/thecuriousanimal/testlink.html
Original Answer
You need to add Jekyll Front Matter to your new page (i.e. testlink.md) and specify the a Jekyll layout. In your situation, your new page needs the same layout as the index.md from the GitHub Jekyll Hacker theme. See the layout specified at the top of index.md.

github pages fails to convert .md in table to .html

Markdown tables are rendered in a lopsided fashion, and I've used html coding in a markdown (.md) file to get something that looks reasonable to me. That seems to cause a problem when my .md files are converted to .html github pages (jekyll).
It seems that any links (e.g. somefile.md) in the html-coded table are not converted to the .html extension; in other words, the link in the github pages page is to somefile.md instead of somefile.html. Following a link then yields a really ugly .md file.
This is an awkward description (github pages page = inane). I've created a version of my README.md file here that includes both the markdown-coded table, and the html-coded table. If you'll follow that link, the issue will be obvious I think.
I would like to have a table that looks rational (not lopsided), and have my links converted properly by github pages. Is this possible?

Is there a way to create a simple Markdown wiki with GitHub pages?

I want to use GitHub pages to write and host my own system administration wiki in Markdown.
I already created a repository with myname.github.io and placed in it only one file index.html with the text:
Hello world!
As the result I want a structured Markdown wiki, for example:
index.html
io/mdadm.md
io/lvm.md
io/disks.md
mail/postfix.md
mail/mail.md
bacula/setup.md
bacula/tips.md
bash/tips.md
system/applications/repositories.md
When I will navigate to http://myname.github.io I want to see the main page with links to another. I will create the main page in HTML manually.
When I will navigate to http://myname.github.io/system/applications/repositories or something else I want to see rendered Markdown HTML.
How can I create this layout and force GitHub to render Markdown files into HTML?
Is there a better way to use GitHub as a free wiki?
I also understand that I can use standard md files in a repository and default GitHub repository interface. But this interface is over complicated, compared to pure HTML rendered from Markdown.
You can use Jekyll, the static site generator which works very well with GitHub pages and uses Markdown out of the box.
See documentation here.

Can I use a Markdown file in a GitHub page?

Since the GitHub wiki does not support directories, I want to put my md files into GitHub pages. However when I open them I found they are not interpreted at all. GitHub just gives me the raw file. See http://greenlaw110.github.com/Rythm/en/index.md. Any idea?
The documentation isn't particularly clear on this, but given that the Markdown rendering is done by Jekyll, I believe you need what they call "YAML front matter" for it to compile the page. So try putting this at the top of your file:
---
title: Document Center
---
That should be enough to trigger Jekyll. (And then you can get fancy and start using layouts, etc.)
Another reason (found by experience) why you might get a raw index.md file, is if you happen to also have a similarly-named index.html file. This blocks GH Pages.
Deleting index.html produces (on the site) a new index.html with parsed markdown. The original index.md is then no longer accessible.

GitHub Pages: How do I edit this page in markdown format, just as I created it?

I'm not too comfortable with touching the generated HTML that the site gives, I was wondering whether there is any way to change the contents of my page in markdown formatting, the same way that I did upon creating the page?
Any input as to go about doing this would be awesome.
By default, GitHub Pages helps you generate html pages only.
But if you setup your site to use jekyll, then you can store files in markdown. For example, in the _posts section of this repo 'cboettig/labnotebook' which is generated to carlboettiger.info.
See Help page "Using Jekyll with Pages"
More specifically (as highlighted in esfandia's answer), see "The Automatic Page Generator", which allows for markdown editing.
As commented by dregad, there is a new theme chooser in Dec. 2016:
See this article by Antriksh Yadav:
Update August 2016: Simpler GitHub Pages publishing now allows to keep your page files in a subfolder of the same branch (no more gh-pages needed):
So you don't need multiple branch anymore.
If you replace index.html with index.md containing your original markdown text, and add a "Front Matter" section at the top, then you can do your page editing in markdown.
It's totally possible and supported: just go back to "Settings", scroll down to GitHub Pages. The Source you used to create your initial page should still be there, and when you click on "Launch automatic page generator" it will allow you to update the markdown code right there in the browser.
When you're done you'll need to select the layout again, but once you're done with that it will create a new index.html, commit it using the GitHub pages source you chose, and publish the modified page.
You need Jekyll. The documentation you are looking for is here: https://help.github.com/articles/using-jekyll-with-pages