GitHub guidelines for working with i18n documents

The W3C Internationalization Activity has task forces which use GitHub for document development. This page provides guidelines to help people contribute content if they are unfamiliar with GitHub. Some of this information is adapted from the web-platform-tests documentation.

For the examples we will use the GitHub username myUserName and we'll use a repository (repo) name, repoName. You should substitute your own username wherever you see myUserName, and the name of the repo you want to work with for repoName.

While this guide covers both command-line and visual tools, we recommend using GitHub Desktop if you are unfamiliar with the terminal. It provides a friendly interface for most of the tasks described here.

Choose your tool:

  • GitHub Desktop: Best for beginners. Visual interface, handles most configuration automatically.
  • Command Line: Powerful and flexible. Standard for many developers.
  • VS Code: Great if you are already using it for editing files.

If you have comments or suggestions about how to improve this page, feel free to raise a GitHub issue.

See also the editorial guidelines.

Setting up GitHub

If you haven't used GitHub before, follow the instructions in this section. Otherwise, skip to the next section.

  1. Create a GitHub account if you do not already have one, on github.com

  2. Download and install the latest version of Git: https://git-scm.com/install/. Please refer to the instructions there for different platforms.

  3. Configure your settings so your commits are properly labeled:

    1. On Mac or Linux, open the Terminal.

      On Windows, open Git Bash (From the Start Menu > Git > Git Bash).

    2. At the prompt, type:

      $ git config --global user.name "Your Name"
      

      This will be the name that is displayed with your submissions.

    3. Next, type:

      $ git config --global user.email "your_email@address.com"
      

      This should be the email address you used to create the account in Step 1.

  4. Set up authentication (GitHub no longer accepts account passwords for Git operations):

    You have two main options:

    For beginners, using the GitHub CLI (gh) to log in is often the easiest path: gh auth login.

Basic overview of how the process works

The repository that you contribute to will depend on the task force you are working with (e.g., alreq). The following diagram and steps illustrate the basic setup and workflow.

Diagram showing parts of the GitHub setup.

In a typical scenario, you will work with three locations:

To contribute changes, you will typically follow this 4-step workflow:

  1. Sync: Regularly update your local copy with changes from the W3C Repo so you are working on the latest version.
  2. Branch: Create a separate "workspace" (called a branch) for each set of related changes. This keeps your experiments separate from the main code.
  3. Edit & Push: Make your changes, save them (commit), and upload them (push) to Your Fork on GitHub.
  4. Propose: Raise a pull request (PR) on GitHub. This asks the W3C editors to review and merge your branch into the official W3C Repo.

How to make your fork

Once you have Git set up, you will need to fork the original repository. This will enable you to submit your proposed changes using a pull request.

  1. In the browser, go to the GitHub page for the W3C repository, e.g. https://github.com/w3c/repoName/.

  2. Click the Fork button in the upper right.

  3. The fork will take several seconds, then you will be redirected to your GitHub page for this forked repository, e.g. https://github.com/myUserName/repoName/.

Cloning your forked repo to your computer

The next step is to clone (download) a copy of your forked repo to your local machine.

Using GitHub Desktop

  1. Go to your fork's page on GitHub (e.g., https://github.com/myUserName/repoName).
  2. Click the green <> Code button.
  3. Select Open with GitHub Desktop.
  4. Follow the prompts in the app to choose a location on your computer and finish cloning.

Using the Command Line

  1. Open your terminal or command prompt.
  2. Use cd to navigate to the folder where you want to keep your project (e.g., cd Documents).
  3. Type the following command:
    $ git clone https://github.com/myUserName/repoName.git
    (Replace myUserName with your GitHub username, and repoName with the name of the repository.)

This will create a subdirectory called repoName containing all the files.

Configuring remotes (Setup upstream)

You should configure your local repo to track the original W3C repository as an "upstream" remote. This allows you to easily pull in changes made by others.

Using GitHub Desktop

GitHub Desktop usually detects that your repository is a fork and sets up the "upstream" remote for you automatically. You often don't need to do anything here!

Using the Command Line

  1. On the command line, navigate to your project directory:

    $ cd <pathname>/repoName

    (Remember the Pro tip: type cd and drag the folder into the terminal.)

  2. Check your current remotes:

    $ git remote -v

    It should show origin pointing to your fork. If upstream is missing, add it:

    $ git remote add upstream https://github.com/w3c/repoName.git

Synchronising your local files and your fork with the W3C repo

You should regularly bring your local copy of the files up-to-date with the latest commits in the W3C repository.

Using GitHub Desktop

  1. Click the Fetch origin (or Fetch upstream) button at the top of the app.
  2. If there are new changes, click Update from upstream (or Pull origin).
  3. To push these changes to your fork on GitHub, click Push origin.

Using the Command Line

  1. On the command line, navigate to your project directory.

  2. Make sure that you are on the default branch (e.g., gh-pages or main).

    $ git checkout gh-pages
  3. To pull in changes from the W3C repository, first fetch them:

    $ git fetch upstream

    Then merge them into your local branch:

    $ git merge upstream/gh-pages
  4. Finally, push these changes to your fork on GitHub too:

    $ git push origin gh-pages

For additional information, please see the GitHub docs.

Making changes and proposing them

Now we describe steps to create content and how to request that the changes be merged into the content on the W3C repo.

Before you start on these steps, ensure that you have fetched the latest files from the W3C repo by following the steps in the previous section!

Also, ensure that you start from the gh-pages branch before creating a new feature branch.

Create a new branch

A branch is a separate workspace for your changes.

Using GitHub Desktop

  1. Click on the Current Branch button at the top.
  2. Click New Branch.
  3. Give it a descriptive name (e.g., arabic-joining-forms) and click Create Branch.

Using the Command Line

Check you are on the gh-pages branch:

$ git checkout gh-pages

Then create and switch to a new branch:

$ git checkout -b myBranchName

Make the changes to your content

Edit the files you want to change or create.

Prepare your files for submission

Using GitHub Desktop

  1. The app will show you a list of "Changed files" on the left.
  2. Type a short description in the Summary box at the bottom left (e.g., "New section on Arabic joining forms").
  3. Click Commit to [your branch name].

Using the Command Line

  1. Tell git to add the files you'd like to commit:

    $ git add [file1] [file2]
  2. Once you've added everything, you can commit and add a message:

    $ git commit -m "New section on Arabic joining forms"

Request that your changes be incorporated into the W3C repo

Using GitHub Desktop

  1. Click Publish branch (or Push origin) at the top.
  2. Click Create Pull Request. This will open your web browser to the GitHub website.

Using the Command Line

  1. Push your branch to your fork on the server:

    $ git push origin myBranchName
  2. Go to your fork on GitHub in the browser.

Finishing on GitHub

  1. Click the "Compare & pull request" button that usually appears, or go to the "Pull requests" tab and click "New pull request".
  2. Add a descriptive title and comment explaining your changes, then click "Create pull request".

  3. Wait for feedback. Reviewers may suggest changes before merging.

Modify your submission

If a reviewer asks for changes, follow these steps:

  1. Ensure you are on your feature branch:

    $ git checkout myBranchName
  2. Make the changes and commit them just like before.

  3. Push the changes to your fork:

    $ git push origin myBranchName
  4. The pull request will automatically be updated with the new commit.

Cleaning up

Once your pull request has been accepted and merged:

  1. Delete your branch on GitHub using the 'Delete Branch' button in the PR.
  2. Or on the command line:
    $ git push origin --delete myBranchName
  3. Switch back to your main branch and sync:
    $ git checkout gh-pages
    $ git fetch upstream
    $ git merge upstream/gh-pages
    $ git push origin gh-pages

GitHub hints & tips

See an HTML version of a page

To see how your changes look in a browser, you can use the following methods:

  1. Netlify Deploy Preview: This is the recommended way to view changes in a pull request. Once you have created a pull request, Netlify will automatically build a preview of your changes. You can find the link in a comment by the netlify bot.

  2. Local Server: If you want to see your changes before committed and pushing them, you can simply open the HTML file in your browser directly from your local repository on your computer.

Publishing with Echidna

Follow these steps to quickly and easily publish your document to /TR space. It is good to keep differences between the editor's draft on GitHub and version on /TR as small as possible. Echidna makes it possible to self-publish at any time, without having to wait for the webmaster's help.

Note that you can't publish First Public Working Drafts using Echidna. That has to go through the normal process.

Setting things up

Ask your staff contact to do the following:

  1. Get a token for your spec from the W3C. You'll need to keep this somewhere safe for when you want to publish the document.

  2. Set the w3cid variable inside the document for the editors who will be doing the actual publication.

  3. Add a config file for the document on GitHub.

Actually publishing

Follow these steps:

  1. Check that the GitHub.io Editor's Draft (ED) is valid HTML using the HTML5 validator.
  2. Check that all links work using the W3C Link Checker.
  3. Run a spell checker over the document.
  4. Update the config file for the document so that it lists all images and other dependant files. The config file will be at the top level of the GitHub repo, and usually has the name of the document, without an extension.
  5. Go to the Pubrules checker and run it against the following URL:
    https://labs.w3.org/spec-generator/?type=respec&url=https://w3c.github.io/linkToYourSpec/?specStatus=WD&shortName=theShortName
    Fix anything that's needed, and rerun the checker until it's ok. You will probably find that the checker complains about not being able to find a dependent file (usually the .css file). That's because the URL above creates a WD version of your main file in a new location for testing, and doesn't copy over the dependent files. You can ignore those messages, but you should double-check that the config file lists all dependent files.
  6. Open a terminal window and run the following Curl statement:
    curl 'https://labs.w3.org/echidna/api/request' --data 'url=echidnaConfigURL&decision=decisionUrlOnMailingList&token=documentToken'

    Note: curl is a command-line tool. If you are on Windows and curl is not found, you can use Git Bash.

  7. Go to the TR-Notification list to check whether the document was successfully published.